> ## Documentation Index
> Fetch the complete documentation index at: https://praison.ai/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# Spawn Sub Agent • AI Agent SDK

> spawn_sub_agent: Spawn a sub-agent for non-blocking execution (sync version).

# spawn\_sub\_agent

Method

> This is a method of the [**AgentTeam**](https://praison.ai/docs/sdk/reference/praisonaiagents/classes/AgentTeam.md) class in the [**agents**](https://praison.ai/docs/sdk/reference/praisonaiagents/modules/agents.md) 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.

```mermaid theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
%%{init: {'theme': 'base', 'themeVariables': { 'primaryColor': '#8B0000', 'primaryTextColor': '#fff', 'primaryBorderColor': '#710101', 'lineColor': '#189AB4', 'secondaryColor': '#189AB4', 'tertiaryColor': '#fff' }}}%%

graph LR
    input["Input Data"] --> agent["Agent: spawn_sub_agent"]
    agent --> output["Output Result"]
    style agent fill:#8B0000,color:#fff
    style input fill:#8B0000,color:#fff
    style output fill:#8B0000,color:#fff
```

## Signature

```python theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
def spawn_sub_agent(agent: Agent, task: Any, completion_callback: Optional[Callable[[SubAgentCompletionEvent], Any]], metadata: Optional[Dict[str, Any]]) -> SpawnedSubAgent
```

## Parameters

**agent** `Agent` *required*

No description available.

**task** `Any` *required*

No description available.

**completion\_callback** `Optional`

No description available.

**metadata** `Optional`

No description available.

### Returns

**Returns** `SpawnedSubAgent`

The result of the operation.

## Uses

* `uuid.uuid4`
* `EventBus`
* `subscribe`
* `SpawnedSubAgent`
* `time.time`
* `publish`
* `agent.start`
* `announce_completion`
* `threading.Thread`
* `spawn_thread.start`

## Source

> [card] [View on GitHub](https://github.com/MervinPraison/PraisonAI/blob/main/src/praisonai-agents/praisonaiagents/agents/agents.py#L4469)
>
> `praisonaiagents/agents/agents.py` at line 4469

***

## Related Documentation

> [card] [Agents Concept](https://praison.ai/docs/docs/concepts/agents)

> [card] [Single Agent Guide](https://praison.ai/docs/docs/guides/single-agent)

> [card] [Multi-Agent Guide](https://praison.ai/docs/docs/guides/multi-agent)

> [card] [Agent Configuration](https://praison.ai/docs/docs/configuration/agent-config)

> [card] [Auto Agents](https://praison.ai/docs/docs/features/autoagents)


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.