Skip to main content
This example demonstrates building a task planning agent that breaks down tasks into steps and uses a stop condition to know when it’s done.

Features

  • Multi-step task execution
  • has_tool_call stop condition
  • Step callbacks for monitoring
  • Explicit completion signaling

Complete Code

How It Works

  1. Plan Creation - The AI creates a structured plan for the goal
  2. Step Execution - Each step is executed using the execute_step tool
  3. Stop Condition - The loop stops when finish_task is called
  4. Monitoring - Callbacks track each step’s progress

Sample Output

Key Concepts

Stop Conditions

Step Callbacks

Customization Ideas

Modify execute_step to handle multiple steps concurrently.
Add a tool for handling failures and retrying steps.
Save completed tasks to a database for long-running workflows.