Quick Start
How It Works
| Step | Description |
|---|---|
| Validation | Payload validated against Pydantic schema |
| Serialization | Valid payload converted to structured JSON |
| Handoff | Target agent receives formatted JSON context |
| Error Handling | Schema mismatches raise HandoffValidationError |
Configuration
| Parameter | Type | Default | Description |
|---|---|---|---|
agent | Agent | Required | Target agent to hand off to |
input_schema | Type[BaseModel] | Required | Pydantic model class for validation |
tool_name_override | str | None | Custom tool name |
tool_description_override | str | None | Custom tool description |
on_handoff | Callable | None | Callback when handoff starts |
input_filter | Callable | None | Function to filter input data |
config | HandoffConfig | None | Advanced handoff configuration |
Accepted Payload Types
| Payload type | Behaviour |
|---|---|
Instance of input_schema | Re-validated via model_dump() |
dict | Validated directly |
Any Pydantic model with model_dump() | Converted to dict, validated |
Object with __dict__ | Vars extracted, validated |
str | Bypasses validation — falls back to plain Handoff (backward compatibility) |
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

