Quick Start
1
Define Schema + Create TypedHandoff
2
Execute with Validated Payload
3
Invalid Payload Raises Immediately
How It Works
Configuration
Accepted Payload Types
Common Patterns
Research → Writer Pipeline
Customer Info Pipeline
Async Typed Handoffs
Combining with HandoffConfig
Receiving agent: input_payload_schema
Use input_payload_schema on the receiving agent to declare the Pydantic model it expects as incoming payload. This ensures that any agent sending data to this agent produces a payload that matches the declared schema — mismatches raise HandoffValidationError at the boundary.
TypedHandoff(agent=receiver, input_schema=DeployPayload).execute_programmatic(...) with an invalid payload, HandoffValidationError is raised:
Best Practices
Keep schemas small
Keep schemas small
Only include fields the receiving agent actually needs. Large schemas increase validation overhead and complexity.
Wrap execute_programmatic in try/except
Wrap execute_programmatic in try/except
Always catch
HandoffValidationError at orchestration boundaries to handle schema mismatches gracefully:Inspect validation_errors for remediation
Inspect validation_errors for remediation
Use
e.validation_errors to surface field-level issues to users:Prefer typed handoffs for multi-field contracts
Prefer typed handoffs for multi-field contracts
Use typed handoffs when passing more than 2 fields between agents. The validation cost is much lower than debugging wrong LLM output.
Handle Pydantic dependency
Handle Pydantic dependency
TypedHandoff requires Pydantic. Document the requirement:Instantiating without Pydantic raises
ImportError.Related
Handoffs
Plain handoffs (string payloads, no validation)
Handoff Filters
Filtering conversation history during handoffs
Handoff Config
Timeouts, retries, concurrency settings
Multi-Agent Patterns
Design patterns for agent collaboration

