Parallel Handoffs • AI Agent SDK
parallel_handoffs: Execute multiple handoffs in parallel with concurrency control.
parallel_handoffs
Async
Function
</div>
This function is defined in the handoff module.
Execute multiple handoffs in parallel with concurrency control.
This function provides the parallel execution capabilities from SubagentDelegator while using the unified Handoff system.
Signature
async def parallel_handoffs(source: 'Agent', targets: List[tuple], max_concurrent: int, config: Optional[HandoffConfig]) -> List['HandoffResult']Parameters
ParamField
AgentSource agent performing the handoffs
ParamField
List[tuple]List of (agent, prompt) tuples for parallel execution
ParamField
intMaximum concurrent handoffs (overrides config)
ParamField
Optional[HandoffConfig]Optional HandoffConfig for additional settings
Returns
ResponseField
List['HandoffResult']List of HandoffResult objects from each parallel handoff
Usage
results = await parallel_handoffs(
source=main_agent,
targets=[
(research_agent, "Research topic X"),
(analysis_agent, "Analyze data Y"),
(summary_agent, "Summarize findings Z")
],
max_concurrent=3
)Uses
ValueErrorasyncio.Semaphoresource.handoff_to_asynclogger.errorHandoffResultasyncio.gather
Source
View on GitHubpraisonaiagents/agent/handoff.py at line 1407