Defining a Sub-Agent
master_agents parameter controls which agents can delegate to this sub-agent.
How Delegation Works
- The master agent’s LLM decides to delegate and “calls” the sub-agent (it appears as a tool)
- A new
ExecutionContextis created with a childcall_id - The sub-agent runs its own execution loop with its own tools and prompt
- The sub-agent’s response is returned to the master agent
- The master agent incorporates the result and continues
Streaming During Delegation
Whenverbose=True, the client sees events from both the master and sub-agent: