@@ -61,11 +61,70 @@ metadata: # Optional - author, license, readme
6161
6262# ## Task delegation versus conversation handoff
6363
64- Use `sub_agents` to break work into tasks. The root agent assigns work to a
65- sub-agent and gets results back while staying in control.
64+ Agents support two different delegation mechanisms. Choose based on whether you
65+ need task results or conversation control.
6666
67- Use `handoffs` to transfer the entire conversation to a different agent. The new
68- agent takes over completely.
67+ # ### Sub_agents: Hierarchical task delegation
68+
69+ Use `sub_agents` for hierarchical task delegation. The parent agent assigns a
70+ specific task to a child agent using the `transfer_task` tool. The child
71+ executes in its own context and returns results. The parent maintains control
72+ and can delegate to multiple agents in sequence.
73+
74+ This works well for structured workflows where you need to combine results from
75+ specialists, or when tasks have clear boundaries. Each delegated task runs
76+ independently and reports back to the parent.
77+
78+ **Example:**
79+
80+ ` ` ` yaml
81+ agents:
82+ root:
83+ sub_agents: [researcher, analyst]
84+ instruction: |
85+ Delegate research to researcher.
86+ Delegate analysis to analyst.
87+ Combine results and present findings.
88+ ` ` `
89+
90+ Root calls : ` transfer_task(agent="researcher", task="Find pricing data")` . The
91+ researcher completes the task and returns results to root.
92+
93+ # ### Handoffs: Conversation transfer
94+
95+ Use `handoffs` to transfer conversation control to a different agent. When an
96+ agent uses the `handoff` tool, the new agent takes over completely. The
97+ original agent steps back until someone hands back to it.
98+
99+ This works well when different agents should own different parts of an ongoing
100+ conversation, or when specialists need to collaborate as peers without a
101+ coordinator managing every step.
102+
103+ **Example:**
104+
105+ ` ` ` yaml
106+ agents:
107+ generalist:
108+ handoffs: [database_expert, security_expert]
109+ instruction: |
110+ Help with general development questions.
111+ If the conversation moves to database optimization,
112+ hand off to database_expert.
113+ If security concerns arise, hand off to security_expert.
114+
115+ database_expert:
116+ handoffs: [generalist, security_expert]
117+ instruction: Handle database design and optimization.
118+
119+ security_expert:
120+ handoffs: [generalist, database_expert]
121+ instruction: Review code for security vulnerabilities.
122+ ` ` `
123+
124+ When the user asks about query performance, generalist executes :
125+ ` handoff(agent="database_expert")` . The database expert now owns the
126+ conversation and can continue working with the user directly, or hand off to
127+ security_expert if the discussion shifts to SQL injection concerns.
69128
70129# ## Commands
71130
0 commit comments