Overview
Human-in-the-Loop (HITL) workflows pause execution to collect input from humans, then resume based on the response. Use cases include:- Approval workflows: Review and approve agent actions
- Ambiguous decisions: Escalate to humans when AI is uncertain
- Quality control: Human review before final output
- Data collection: Gather additional context from users
How It Works
- Request: Executor calls
ctx.request_info()with request data - Pause: Workflow pauses and emits a
request_infoevent - Human Response: External system collects response
- Resume: Workflow resumes with response data
- Handle Response: Executor’s
@response_handlerprocesses the response

Basic Pattern
Request Information
Usectx.request_info() to pause and request input:
Python
Handle Response
Use@response_handler to process the human response:
Python
Running with Human Input
Interactive Workflow
Collect input during execution:Python
Pre-supplied Responses
Provide responses when resuming from checkpoint:Python
Complete Example: Content Review Workflow
A workflow where an agent drafts content and a human reviews it:Checkpoint Integration
Combine HITL with checkpoints for durable pause/resume:Python
Multiple Concurrent Requests
Handle multiple request-info calls in parallel:Python
Typed Request-Response
Use dataclasses for type-safe request-response:Python
Best Practices
Request Design
Request Design
- Use clear, specific prompts in request data
- Include context needed for human decision
- Use structured data (dataclasses, Pydantic models) for type safety
- Provide sensible defaults when possible
Response Handling
Response Handling
- Validate responses before processing
- Handle unexpected responses gracefully
- Provide feedback to user about what happens next
- Log all request-response pairs for audit
Checkpoint Strategy
Checkpoint Strategy
- Always use checkpoint storage for HITL workflows
- Test checkpoint restore with pending requests
- Document what happens if response is never provided
- Implement timeouts for critical workflows
User Experience
User Experience
- Show clear request IDs for tracking
- Display relevant context with each request
- Support bulk response collection
- Provide status indicators (pending, responded, processed)
Advanced Patterns
Escalation Pattern
Escalate to human only when AI is uncertain:Python
Tool Approval Pattern
Require approval before executing sensitive tools:Python
Next Steps
Checkpoints
Learn more about checkpoint integration with HITL
Orchestration Patterns
Explore workflow orchestration patterns