agents.examples.human_in_the_loop
Human in the Loop example.
Demonstrates an agent that generates task plans requiring human approval. The agent creates a list of steps and waits for the user to approve, modify, or reject them before proceeding.
Features:
- Task planning with step generation
- State snapshot events for plan creation
- Human review/approval workflow
This pattern is useful for:
- Approval workflows
- Code review automation
- Deployment pipelines
- Any multi-step task requiring human oversight
TaskStep Objects
class TaskStep(BaseModel)
A step in a task plan.
TaskPlan Objects
class TaskPlan(BaseModel)
A task plan with multiple steps for human review.
generate_task_steps
@agent.tool_plain
async def generate_task_steps(steps: list[str]) -> StateSnapshotEvent
Generate a list of task steps for the user to review and approve.
This creates a task plan that will be displayed to the user. The user can enable/disable steps before confirming execution.
Arguments:
steps- List of step descriptions (brief imperative commands).
Returns:
StateSnapshotEvent containing the task plan for user review.