Sub-agents
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.
Slash command
Use/subagents to inspect or control sub-agent runs for the current session:
/subagents list/subagents stop <id|#|all>/subagents log <id|#> [limit] [tools]/subagents info <id|#>/subagents send <id|#> <message>
/subagents info shows run metadata (status, timestamps, session id, transcript path, cleanup).
Primary goals:
- Parallelize “research / long task / slow tool” work without blocking the main run.
- Keep sub-agents isolated by default (session separation + optional sandboxing).
- Keep the tool surface hard to misuse: sub-agents do not get session tools by default.
- Avoid nested fan-out: sub-agents cannot spawn sub-agents.
agents.defaults.subagents.model or per-agent overrides.
Tool
Usesessions_spawn:
- Starts a sub-agent run (
deliver: false, global lane:subagent) - Then runs an announce step and posts the announce reply to the requester chat channel
- Default model: inherits the caller unless you set
agents.defaults.subagents.model(or per-agentagents.list[].subagents.model); an explicitsessions_spawn.modelstill wins.
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?(default0; when set, the sub-agent run is aborted after N seconds)cleanup?(delete|keep, defaultkeep)
agents.list[].subagents.allowAgents: list of agent ids that can be targeted viaagentId(["*"]to allow any). Default: only the requester agent.
- Use
agents_listto see which agent ids are currently allowed forsessions_spawn.
- Sub-agent sessions are automatically archived after
agents.defaults.subagents.archiveAfterMinutes(default: 60). - Archive uses
sessions.deleteand renames the transcript to*.deleted.<timestamp>(same folder). cleanup: "delete"archives immediately after announce (still keeps the transcript via rename).- Auto-archive is best-effort; pending timers are lost if the gateway restarts.
runTimeoutSecondsdoes not auto-archive; it only stops the run. The session remains until auto-archive.
Authentication
Sub-agent auth is resolved by agent id, not by session type:- The sub-agent session key is
agent:<agentId>:subagent:<uuid>. - The auth store is loaded from that agent’s
agentDir. - The main agent’s auth profiles are merged in as a fallback; agent profiles override main profiles on conflicts.
Announce
Sub-agents report back via an announce step:- The announce step runs inside the sub-agent session (not the requester session).
- If the sub-agent replies exactly
ANNOUNCE_SKIP, nothing is posted. - Otherwise the announce reply is posted to the requester chat channel via a follow-up
agentcall (deliver=true). - Announce replies preserve thread/topic routing when available (Slack threads, Telegram topics, Matrix threads).
- Announce messages are normalized to a stable template:
Status:derived from the run outcome (success,error,timeout, orunknown).Result:the summary content from the announce step (or(not available)if missing).Notes:error details and other useful context.
Statusis not inferred from model output; it comes from runtime outcome signals.
- Runtime (e.g.,
runtime 5m12s) - Token usage (input/output/total)
- Estimated cost when model pricing is configured (
models.providers.*.models[].cost) sessionKey,sessionId, and transcript path (so the main agent can fetch history viasessions_historyor inspect the file on disk)
Tool Policy (sub-agent tools)
By default, sub-agents get all tools except session tools:sessions_listsessions_historysessions_sendsessions_spawn
Concurrency
Sub-agents use a dedicated in-process queue lane:- Lane name:
subagent - Concurrency:
agents.defaults.subagents.maxConcurrent(default8)
Stopping
- Sending
/stopin the requester chat aborts the requester session and stops any active sub-agent runs spawned from it.
Limitations
- Sub-agent announce is best-effort. If the gateway restarts, pending “announce back” work is lost.
- Sub-agents still share the same gateway process resources; treat
maxConcurrentas a safety valve. sessions_spawnis always non-blocking: it returns{ status: "accepted", runId, childSessionKey }immediately.- Sub-agent context only injects
AGENTS.md+TOOLS.md(noSOUL.md,IDENTITY.md,USER.md,HEARTBEAT.md, orBOOTSTRAP.md).
