delegate_subagent tool lets the parent agent delegate a focused sub-task to a separate ReAct loop instance with its own context window. The subagent runs, burns its own tokens, and returns only the final summary — its tool calls, intermediate reasoning, and raw outputs stay isolated in the sub-session and never pollute the parent’s context.
This is the same pattern that projects like Claude Code call “Task” subagents, and it solves a classic problem: analyses over large payloads (Prometheus /metrics, verbose logs, exhaustive repo searches) that would otherwise consume tens of thousands of tokens just feeding raw data into the main agent’s history.
When to use
Syntax
The tool is exposed asdelegate_subagent in native function calling, and as the delegate subcommand of @coder in the XML form:
- Native (preferred)
- XML (/coder mode)
Parameters
What the parent receives
The output returned to the main agent is the subagent’s final string, prefixed with a header carrying telemetry metadata:Limits and protections
The depth limit protects against pathological recursion (subagent delegating to a subagent that delegates…). The main agent’s first call is depth 0; each nested
delegate_subagent increments.
Tools allowlist
By default the subagent receives a safe read-only set:read_only: false and list which ones:
read_only: true + tools: [...] containing a write tool results in a runtime block — read_only takes precedence.
Differences from other delegation forms
Full example — metrics analysis
Scenario: the user asks for a memory-spike diagnosis. Withoutdelegate_subagent, the agent would web_fetch the /metrics, receive 50K chars in context, and burn tokens analysing the raw payload turn after turn.
With delegation:
webfetch (with the filter already applied), does a second pass if needed, and returns a ~500-char summary. The main agent hands that summary to the user without ever seeing the raw payload.
Next Steps
Multi-Agent
For parallel tasks instead of isolated delegation.
Session Workspace
The scratch dir shared between parent and subagent.
Tool Result Management
How the subagent’s output gets truncated if it’s too big.
Web Tools
@webfetch filters that pair well with delegation.