Graph Architecture
The execution flow follows this graph: Each node receives and returns anAgentState dict containing:
user_message- Current user inputconversation_history- Previous messagesactions- Planned tool invocationsresults- Tool execution resultsfinal_response- Generated response for user
Core Nodes
plan_actions
Purpose: Plans which tools to execute based on user request Location:agent/graph/nodes/plan_actions.py
Key features:
- Uses meta-tools (discover_tools, get_tool_schema, invoke_tool)
- Supports both DSPy and legacy LangChain modes
- Handles multi-step tool calling
- Identifies destructive operations
agent/graph/nodes/plan_actions.py
actions- List of tool invocations with IDs and dependenciesresults- Results from tools executed during planningrequires_confirmation- Whether user confirmation is neededdiscovered_tools- Tools found via discovery
route_execution
Purpose: Determines execution strategy based on action dependencies Location:agent/graph/nodes/route_execution.py
agent/graph/nodes/route_execution.py
confirm_actions
Purpose: Handles human-in-the-loop confirmation for destructive operations Location:agent/graph/nodes/confirm_actions.py
agent/graph/nodes/confirm_actions.py
execute_tools_parallel
Purpose: Executes independent actions concurrently Location:agent/graph/nodes/execute_tools.py
agent/graph/nodes/execute_tools.py
execute_tools_sequential
Purpose: Executes actions respecting dependencies via topological sort Location:agent/graph/nodes/execute_tools.py
agent/graph/nodes/execute_tools.py
synthesize_response
Purpose: Converts tool results into natural language response Location:agent/graph/nodes/synthesize_response.py
agent/graph/nodes/synthesize_response.py
Creating Custom Nodes
Node Best Practices
Pure Functions
Nodes should be pure functions that don’t modify state in place. Always return a new state dict.
Error Handling
Wrap risky operations in try-except and set the
error key in state for downstream handling.State Minimization
Only add necessary keys to state. Avoid storing large objects that don’t need to flow through the graph.
Logging
Add logging for debugging but avoid excessive output in production.
Dependency Injection Pattern
Nodes that need external dependencies (LLM, services) receive them via closures:See Also
Custom Tools
Add new tools that your nodes can invoke
Testing
Learn how to test custom nodes