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

python
async def parallel_handoffs(source: 'Agent', targets: List[tuple], max_concurrent: int, config: Optional[HandoffConfig]) -> List['HandoffResult']

Parameters

ParamField Agent

Source agent performing the handoffs

ParamField List[tuple]

List of (agent, prompt) tuples for parallel execution

ParamField int

Maximum 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

python
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

  • ValueError
  • asyncio.Semaphore
  • source.handoff_to_async
  • logger.error
  • HandoffResult
  • asyncio.gather

Source

View on GitHub

praisonaiagents/agent/handoff.py at line 1407


Related Documentation