Sub-agents are background agent runs spawned from an existing agent run. They run in their own session (agent:<agentId>:subagent:<uuid>) and, when finished, announce their result back to the requester chat channel.
Use /subagents to inspect or control sub-agent runs for the current session:
/subagents list/subagents kill <id|#|all>/subagents log <id|#> [limit] [tools]/subagents info <id|#>/subagents send <id|#> <message>/subagents steer <id|#> <message>/subagents spawn <agentId> <task> [--model <model>] [--thinking <level>]/subagents info shows run metadata (status, timestamps, session id, transcript path, cleanup).
/subagents spawn starts a background sub-agent as a user command, not an internal relay, and it sends one final completion update back to the requester chat when the run finishes.
agent delivery first with a stable idempotency key.Result (assistant reply text, or latest toolResult if the assistant reply is empty)Status (completed successfully / failed / timed out)--model and --thinking override defaults for that specific run.info/log to inspect details and output after completion.Primary goals:
Cost note: each sub-agent has its own context and token usage. For heavy or repetitive
tasks, set a cheaper model for sub-agents and keep your main agent on a higher-quality model.
You can configure this via agents.defaults.subagents.model or per-agent overrides.
Use sessions_spawn:
deliver: false, global lane: subagent)agents.defaults.subagents.model (or per-agent agents.list[].subagents.model); an explicit sessions_spawn.model still wins.agents.defaults.subagents.thinking (or per-agent agents.list[].subagents.thinking); an explicit sessions_spawn.thinking still wins.Tool params:
task (required)label? (optional)agentId? (optional; spawn under another agent id if allowed)model? (optional; overrides the sub-agent model; invalid values are skipped and the sub-agent runs on the default model with a warning in the tool result)thinking? (optional; overrides thinking level for the sub-agent run)runTimeoutSeconds? (default 0; when set, the sub-agent run is aborted after N seconds)cleanup? (delete|keep, default keep)Allowlist:
agents.list[].subagents.allowAgents: list of agent ids that can be targeted via agentId (["*"] to allow any). Default: only the requester agent.Discovery:
agents_list to see which agent ids are currently allowed for sessions_spawn.Auto-archive:
agents.defaults.subagents.archiveAfterMinutes (default: 60).sessions.delete and renames the transcript to *.deleted.<timestamp> (same folder).cleanup: "delete" archives immediately after announce (still keeps the transcript via rename).runTimeoutSeconds does not auto-archive; it only stops the run. The session remains until auto-archive.By default, sub-agents cannot spawn their own sub-agents (maxSpawnDepth: 1). You can enable one level of nesting by setting maxSpawnDepth: 2, which allows the orchestrator pattern: main → orchestrator sub-agent → worker sub-sub-agents.
{
agents: {
defaults: {
subagents: {
maxSpawnDepth: 2, // allow sub-agents to spawn children (default: 1)
maxChildrenPerAgent: 5, // max active children per agent session (default: 5)
maxConcurrent: 8, // global concurrency lane cap (default: 8)
},
},
},
}
| Depth | Session key shape | Role | Can spawn? |
|---|---|---|---|
| 0 | agent:<id>:main |
Main agent | Always |
| 1 | agent:<id>:subagent:<uuid> |
Sub-agent (orchestrator when depth 2 allowed) | Only if maxSpawnDepth >= 2 |
| 2 | agent:<id>:subagent:<uuid>:subagent:<uuid> |
Sub-sub-agent (leaf worker) | Never |
Results flow back up the chain:
Each level only sees announces from its direct children.
maxSpawnDepth >= 2): Gets sessions_spawn, subagents, sessions_list, sessions_history so it can manage its children. Other session/system tools remain denied.maxSpawnDepth == 1): No session tools (current default behavior).sessions_spawn is always denied at depth 2. Cannot spawn further children.Each agent session (at any depth) can have at most maxChildrenPerAgent (default: 5) active children at a time. This prevents runaway fan-out from a single orchestrator.
Stopping a depth-1 orchestrator automatically stops all its depth-2 children:
/stop in the main chat stops all depth-1 agents and cascades to their depth-2 children./subagents kill <id> stops a specific sub-agent and cascades to its children./subagents kill all stops all sub-agents for the requester and cascades.Sub-agent auth is resolved by agent id, not by session type:
agent:<agentId>:subagent:<uuid>.agentDir.Note: the merge is additive, so main profiles are always available as fallbacks. Fully isolated auth per agent is not supported yet.
Sub-agents report back via an announce step:
ANNOUNCE_SKIP, nothing is posted.agent call (deliver=true).Status: derived from the run outcome (success, error, timeout, or unknown).Result: the summary content from the announce step (or (not available) if missing).Notes: error details and other useful context.Status is not inferred from model output; it comes from runtime outcome signals.Announce payloads include a stats line at the end (even when wrapped):
runtime 5m12s)models.providers.*.models[].cost)sessionKey, sessionId, and transcript path (so the main agent can fetch history via sessions_history or inspect the file on disk)By default, sub-agents get all tools except session tools and system tools:
sessions_listsessions_historysessions_sendsessions_spawnWhen maxSpawnDepth >= 2, depth-1 orchestrator sub-agents additionally receive sessions_spawn, subagents, sessions_list, and sessions_history so they can manage their children.
Override via config:
{
agents: {
defaults: {
subagents: {
maxConcurrent: 1,
},
},
},
tools: {
subagents: {
tools: {
// deny wins
deny: ["gateway", "cron"],
// if allow is set, it becomes allow-only (deny still wins)
// allow: ["read", "exec", "process"]
},
},
},
}
Sub-agents use a dedicated in-process queue lane:
subagentagents.defaults.subagents.maxConcurrent (default 8)/stop in the requester chat aborts the requester session and stops any active sub-agent runs spawned from it, cascading to nested children./subagents kill <id> stops a specific sub-agent and cascades to its children.maxConcurrent as a safety valve.sessions_spawn is always non-blocking: it returns { status: "accepted", runId, childSessionKey } immediately.AGENTS.md + TOOLS.md (no SOUL.md, IDENTITY.md, USER.md, HEARTBEAT.md, or BOOTSTRAP.md).maxSpawnDepth range: 1–5). Depth 2 is recommended for most use cases.maxChildrenPerAgent caps active children per session (default: 5, range: 1–20).