Features
- Multi-step task execution
has_tool_callstop condition- Step callbacks for monitoring
- Explicit completion signaling
Complete Code
How It Works
- Plan Creation - The AI creates a structured plan for the goal
-
Step Execution - Each step is executed using the
execute_steptool -
Stop Condition - The loop stops when
finish_taskis called - Monitoring - Callbacks track each stepβs progress
Sample Output
Key Concepts
Stop Conditions
Step Callbacks
Customization Ideas
Add parallel execution
Add parallel execution
Modify execute_step to handle multiple steps concurrently.
Add error recovery
Add error recovery
Add a tool for handling failures and retrying steps.
Persist task state
Persist task state
Save completed tasks to a database for long-running workflows.