Handoff To • AI Agent SDK
handoff_to: Programmatically hand off a task to another agent.
handoff_to
Method
</div>
Programmatically hand off a task to another agent.
This is the unified programmatic handoff API that replaces delegate(). It uses the same Handoff mechanism as LLM-driven handoffs but can be called directly from code.
Signature
def handoff_to(target_agent: 'Agent', prompt: str, context: Optional[Dict[str, Any]], config: Optional['HandoffConfig']) -> 'HandoffResult'Parameters
ParamField
AgentThe agent to hand off to
ParamField
strThe task/prompt to pass to target agent
ParamField
OptionalOptional additional context dictionary
ParamField
Optional[HandoffConfig]Optional HandoffConfig for advanced settings
Returns
ResponseField
'HandoffResult'HandoffResult with response or error
Usage
result = agent_a.handoff_to(agent_b, "Complete this analysis")
if result.success:
print(result.response)Uses
HandoffHandoffConfighandoff_obj.execute_programmatic
Source
View on GitHubpraisonaiagents/agent/agent.py at line 5659