Skip to main content

handoff_to

Method
This is a method of the Agent class in the agent module.
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

target_agent
Agent
required
The agent to hand off to
prompt
str
required
The task/prompt to pass to target agent
context
Optional
Optional additional context dictionary
config
Optional
Optional HandoffConfig for advanced settings

Returns

Returns
'HandoffResult'
HandoffResult with response or error

Usage

result = agent_a.handoff_to(agent_b, "Complete this analysis")
    if result.success:
        print(result.response)