Spawn Sub Agent • AI Agent SDK
spawn_sub_agent: Spawn a sub-agent for non-blocking execution (sync version).
spawn_sub_agent
Method
</div>
This is a method of the AgentTeam class in the agents module.
Spawn a sub-agent for non-blocking execution (sync version).
Implements the SpawnAnnounceProtocol for efficient parallel sub-agent workflows. Integrates with existing handoff infrastructure to avoid code duplication. Uses threading.Thread for background execution.
Note: For async contexts, use aspawn_sub_agent() which uses asyncio primitives. This method is safe to call from sync contexts only.
Signature
def spawn_sub_agent(agent: Agent, task: Any, completion_callback: Optional[Callable[[SubAgentCompletionEvent], Any]], metadata: Optional[Dict[str, Any]]) -> SpawnedSubAgentParameters
ParamField
AgentNo description available.
ParamField
AnyNo description available.
ParamField
OptionalNo description available.
ParamField
OptionalNo description available.
Returns
ResponseField
SpawnedSubAgentThe result of the operation.
Uses
uuid.uuid4EventBussubscribeSpawnedSubAgenttime.timepublishagent.startannounce_completionthreading.Threadspawn_thread.start
Source
View on GitHubpraisonaiagents/agents/agents.py at line 4469