Handoff To • AI Agent SDK

handoff_to: Programmatically hand off a task to another agent.

handoff_to

Method

</div>

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

python
def handoff_to(target_agent: 'Agent', prompt: str, context: Optional[Dict[str, Any]], config: Optional['HandoffConfig']) -> 'HandoffResult'

Parameters

ParamField Agent

The agent to hand off to

ParamField str

The task/prompt to pass to target agent

ParamField Optional

Optional additional context dictionary

ParamField Optional[HandoffConfig]

Optional HandoffConfig for advanced settings

Returns

ResponseField 'HandoffResult'

HandoffResult with response or error

Usage

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

Uses

  • Handoff
  • HandoffConfig
  • handoff_obj.execute_programmatic

Source

View on GitHub

praisonaiagents/agent/agent.py at line 5659


Related Documentation