Skip to main content
The 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 as delegate_subagent in native function calling, and as the delegate subcommand of @coder in the XML form:

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:
The output is truncated by the same tool result budget that applies to every other tool — so even a chatty subagent has a bounded effect on the parent’s context.

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.
The subagent inherits the same LLM client and model as the parent. There is no per-tool model routing here — for that, use the skill model hints system or dispatch to a custom agent via <agent_call>.

Tools allowlist

By default the subagent receives a safe read-only set:
To grant write or exec tools, you must explicitly set read_only: false and list which ones:
The combination 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. Without delegate_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:
The subagent runs the 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.