3bea1c3d2b
Extracted from: https://github.com/jwwelbor/AgentMap.git Score: 1.0
102 lines
3.9 KiB
Markdown
102 lines
3.9 KiB
Markdown
---
|
|
name: branching-agent-pattern
|
|
version: 1.0.0
|
|
description: Define and execute AI agent workflows using CSV-based declarative definitions
|
|
with configurable branching logic
|
|
inputs:
|
|
- 'CSV workflow files defining agent graphs with columns: graph_name, node_name, agent_type,
|
|
next_node, on_failure, prompt, input_fields, output_field'
|
|
- LLM provider configuration (OpenAI, Anthropic, Google) in agentmap_config.yaml
|
|
- Storage backend configuration in agentmap_config_storage.yaml
|
|
steps:
|
|
- Define workflow graph in CSV with nodes representing agent steps and their connections
|
|
(next_node, on_failure)
|
|
- Configure BranchingAgent with customizable success/failure values and fallback fields
|
|
in the context dictionary
|
|
- Initialize the agent runtime with ensure_initialized() and configure execution tracking
|
|
and state adapter services
|
|
- Execute the workflow using agentmap run with appropriate inputs and monitor the
|
|
execution trace
|
|
outputs:
|
|
- Executed workflow with results stored in the specified output_field
|
|
- Detailed execution trace showing success/failure decisions at each branching point
|
|
- Updated workflow state persisted in the configured storage backend
|
|
tags: []
|
|
metadata:
|
|
source_repo: https://github.com/jwwelbor/AgentMap.git
|
|
extracted_at: ''
|
|
confidence: 0.95
|
|
---
|
|
|
|
# branching-agent-pattern
|
|
|
|
Define and execute AI agent workflows using CSV-based declarative definitions with configurable branching logic
|
|
|
|
## Setup
|
|
|
|
**Dependencies:**
|
|
|
|
```text
|
|
pip install langgraph>=1.0.0 langchain-core>=0.3.0 pyyaml>=6.0.0 fastapi>=0.111.0 uvicorn>=0.34.3
|
|
```
|
|
|
|
**Setup steps:**
|
|
|
|
1. Install AgentMap: pip install agentmap[all]
|
|
1. Configure llm providers in agentmap_config.yaml (OpenAI, Anthropic, Google models)
|
|
1. Create CSV workflow files with graph definitions
|
|
1. Initialize runtime with ensure_initialized()
|
|
1. Run workflow with agentmap run <csv_file> --pretty
|
|
|
|
## Key Files
|
|
|
|
- `agentmap_config.yaml - Main configuration with LLM and storage settings`
|
|
- `agentmap_config_storage.yaml - Storage backend configuration`
|
|
- `hello_world.csv - Sample workflow demonstrating basic agent chain`
|
|
- `examples/host_integration/custom_agents.py - Custom agent implementations with host service integration`
|
|
|
|
## Steps
|
|
|
|
1. Define workflow graph in CSV with nodes representing agent steps and their connections (next_node, on_failure)
|
|
2. Configure BranchingAgent with customizable success/failure values and fallback fields in the context dictionary
|
|
3. Initialize the agent runtime with ensure_initialized() and configure execution tracking and state adapter services
|
|
4. Execute the workflow using agentmap run with appropriate inputs and monitor the execution trace
|
|
|
|
## Implementation Details
|
|
|
|
```python
|
|
CSV format: graph_name,node_name,agent_type,next_node,on_failure,prompt,input_fields,output_field
|
|
```
|
|
|
|
```python
|
|
BranchingAgent context example: {'input_fields': ['success'], 'output_field': 'result', 'success_values': ['PASSED', 'COMPLETED']}
|
|
```
|
|
|
|
```python
|
|
Execution command: agentmap run hello_world.csv --pretty
|
|
```
|
|
|
|
## Inputs
|
|
|
|
- CSV workflow files defining agent graphs with columns: graph_name, node_name, agent_type, next_node, on_failure, prompt, input_fields, output_field
|
|
- LLM provider configuration (OpenAI, Anthropic, Google) in agentmap_config.yaml
|
|
- Storage backend configuration in agentmap_config_storage.yaml
|
|
|
|
## Outputs
|
|
|
|
- Executed workflow with results stored in the specified output_field
|
|
- Detailed execution trace showing success/failure decisions at each branching point
|
|
- Updated workflow state persisted in the configured storage backend
|
|
|
|
## Failure Modes
|
|
|
|
- Invalid CSV format causing parsing errors during workflow loading
|
|
- Missing or misconfigured LLM provider settings leading to execution failures
|
|
- Storage backend unavailable or misconfigured preventing workflow persistence
|
|
- Agent execution timeout due to long-running operations or infinite loops
|
|
|
|
## Source
|
|
|
|
Extracted from: [https://github.com/jwwelbor/AgentMap.git](https://github.com/jwwelbor/AgentMap.git)
|
|
Confidence: 0.95
|