1. Enable swarm mode
Switch the thread to swarm mode so the agent can delegate:2. Send a task that needs delegation
Give the agent a task broad enough that it benefits from help:3. Watch discovery and plan proposal
The agent searches for peers withagent_find and submits a plan. You see both in the stream:
awaiting_approval until you decide.
4. Approve the plan
Approve, reject, or request changes withsdk.agent.decide():
changes_requested, include a feedback field — the agent revises and resubmits.
5. Run the plan and track child agents
Once approved, start execution and watch child agents do their work:Child agent events
Each child event includes a
runKey so you can route its output to the right UI panel if you’re rendering multiple agents side by side.
Delegation without a plan
Not every delegation needs a formal plan. An agent in swarm mode can also useswarm_delegate directly — it finds a peer with agent_find, then hands off a subtask and folds the result into its own response. You’ll see tool_start/tool_end events with toolName: "swarm_delegate" instead of plan events.
Switching back to solo
When you’re done with swarm work, switch back:Next
- Plans and Goals —
/planand/goalin depth - Stream Protocol — every event type including
swarm_child_* - Agent Tools —
agent_findandswarm_delegateevent shapes