handoff • AI Agent SDK
handoff: Create a handoff configuration for delegating tasks to another agent.
handoff
Function
</div>
This function is defined in the handoff module.
Create a handoff configuration for delegating tasks to another agent.
This is a convenience function that creates a Handoff instance with the specified configuration. It supports both the legacy API and the new unified HandoffConfig with tool security boundary enforcement.
Signature
def handoff(agent: 'Agent', tool_name_override: Optional[str], tool_description_override: Optional[str], on_handoff: Optional[Callable], input_type: Optional[type], input_filter: Optional[Callable[[HandoffInputData], HandoffInputData]], config: Optional[HandoffConfig], context_policy: Optional[str], timeout_seconds: Optional[float], max_concurrent: Optional[int], detect_cycles: Optional[bool], max_depth: Optional[int], tool_policy_mode: Optional[Literal['intersect', 'passthrough']], blocked_tools: Optional[List[str]]) -> HandoffParameters
AgentThe target agent to hand off to
Optional[str]Custom tool name (defaults to transfer_to_<agent_name>)
Optional[str]Custom tool description
Optional[Callable]Callback function executed when handoff is invoked
Optional[type]Type of input expected by the handoff (for structured data)
OptionalFunction to filter/transform input before passing to target agent
Optional[HandoffConfig]HandoffConfig for advanced settings
Optional[str]Shorthand for config.context_policy (“full”, “summary”, “none”, “last_n”)
Optional[float]Shorthand for config.timeout_seconds
Optional[int]Shorthand for config.max_concurrent
Optional[bool]Shorthand for config.detect_cycles
Optional[int]Shorthand for config.max_depth
OptionalTool boundary mode (“intersect” = secure by default, “passthrough” = legacy)
OptionalList of tool names to always block regardless of intersection
Returns
HandoffA configured Handoff instance
Usage
from praisonaiagents import Agent, handoff, HandoffConfig, HandoffToolPolicy
billing_agent = Agent(name="Billing Agent")
refund_agent = Agent(name="Refund Agent")
# Simple usage (secure by default - tools intersected)
triage_agent = Agent(
name="Triage Agent",
handoffs=[billing_agent, handoff(refund_agent)]
)
# With tool security config
triage_agent = Agent(
name="Triage Agent",
handoffs=[
handoff(billing_agent,
tool_policy_mode="intersect", # Only shared tools
blocked_tools=["execute_code", "shell_tools"]),
handoff(refund_agent,
config=HandoffConfig(
tool_policy=HandoffToolPolicy(
mode="passthrough", # Legacy behavior
blocked_tools=["dangerous_tool"]
)
))
]
)Uses
HandoffConfigContextPolicyHandoffToolPolicyHandoff
Source
View on GitHubpraisonaiagents/agent/handoff.py at line 1226