* docs: add ACP thread-bound agents plan doc * docs: expand ACP implementation specification * feat(acp): route ACP sessions through core dispatch and lifecycle cleanup * feat(acp): add /acp commands and Discord spawn gate * ACP: add acpx runtime plugin backend * fix(subagents): defer transient lifecycle errors before announce * Agents: harden ACP sessions_spawn and tighten spawn guidance * Agents: require explicit ACP target for runtime spawns * docs: expand ACP control-plane implementation plan * ACP: harden metadata seeding and spawn guidance * ACP: centralize runtime control-plane manager and fail-closed dispatch * ACP: harden runtime manager and unify spawn helpers * Commands: route ACP sessions through ACP runtime in agent command * ACP: require persisted metadata for runtime spawns * Sessions: preserve ACP metadata when updating entries * Plugins: harden ACP backend registry across loaders * ACPX: make availability probe compatible with adapters * E2E: add manual Discord ACP plain-language smoke script * ACPX: preserve streamed spacing across Discord delivery * Docs: add ACP Discord streaming strategy * ACP: harden Discord stream buffering for thread replies * ACP: reuse shared block reply pipeline for projector * ACP: unify streaming config and adopt coalesceIdleMs * Docs: add temporary ACP production hardening plan * Docs: trim temporary ACP hardening plan goals * Docs: gate ACP thread controls by backend capabilities * ACP: add capability-gated runtime controls and /acp operator commands * Docs: remove temporary ACP hardening plan * ACP: fix spawn target validation and close cache cleanup * ACP: harden runtime dispatch and recovery paths * ACP: split ACP command/runtime internals and centralize policy * ACP: harden runtime lifecycle, validation, and observability * ACP: surface runtime and backend session IDs in thread bindings * docs: add temp plan for binding-service migration * ACP: migrate thread binding flows to SessionBindingService * ACP: address review feedback and preserve prompt wording * ACPX plugin: pin runtime dependency and prefer bundled CLI * Discord: complete binding-service migration cleanup and restore ACP plan * Docs: add standalone ACP agents guide * ACP: route harness intents to thread-bound ACP sessions * ACP: fix spawn thread routing and queue-owner stall * ACP: harden startup reconciliation and command bypass handling * ACP: fix dispatch bypass type narrowing * ACP: align runtime metadata to agentSessionId * ACP: normalize session identifier handling and labels * ACP: mark thread banner session ids provisional until first reply * ACP: stabilize session identity mapping and startup reconciliation * ACP: add resolved session-id notices and cwd in thread intros * Discord: prefix thread meta notices consistently * Discord: unify ACP/thread meta notices with gear prefix * Discord: split thread persona naming from meta formatting * Extensions: bump acpx plugin dependency to 0.1.9 * Agents: gate ACP prompt guidance behind acp.enabled * Docs: remove temp experiment plan docs * Docs: scope streaming plan to holy grail refactor * Docs: refactor ACP agents guide for human-first flow * Docs/Skill: add ACP feature-flag guidance and direct acpx telephone-game flow * Docs/Skill: add OpenCode and Pi to ACP harness lists * Docs/Skill: align ACP harness list with current acpx registry * Dev/Test: move ACP plain-language smoke script and mark as keep * Docs/Skill: reorder ACP harness lists with Pi first * ACP: split control-plane manager into core/types/utils modules * Docs: refresh ACP thread-bound agents plan * ACP: extract dispatch lane and split manager domains * ACP: centralize binding context and remove reverse deps * Infra: unify system message formatting * ACP: centralize error boundaries and session id rendering * ACP: enforce init concurrency cap and strict meta clear * Tests: fix ACP dispatch binding mock typing * Tests: fix Discord thread-binding mock drift and ACP request id * ACP: gate slash bypass and persist cleared overrides * ACPX: await pre-abort cancel before runTurn return * Extension: pin acpx runtime dependency to 0.1.11 * Docs: add pinned acpx install strategy for ACP extension * Extensions/acpx: enforce strict local pinned startup * Extensions/acpx: tighten acp-router install guidance * ACPX: retry runtime test temp-dir cleanup * Extensions/acpx: require proactive ACPX repair for thread spawns * Extensions/acpx: require restart offer after acpx reinstall * extensions/acpx: remove workspace protocol devDependency * extensions/acpx: bump pinned acpx to 0.1.13 * extensions/acpx: sync lockfile after dependency bump * ACPX: make runtime spawn Windows-safe * fix: align doctor-config-flow repair tests with default-account migration (#23580) (thanks @osolmaz)
13 KiB
summary, read_when, title
| summary | read_when | title | |||
|---|---|---|---|---|---|
| Sub-agents: spawning isolated agent runs that announce results back to the requester chat |
|
Sub-Agents |
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 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>]
Thread binding controls:
These commands work on channels that support persistent thread bindings. See Thread supporting channels below.
/focus <subagent-label|session-key|session-id|session-label>/unfocus/agents/session ttl <duration|off>
/subagents info shows run metadata (status, timestamps, session id, transcript path, cleanup).
Spawn behavior
/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.
- The spawn command is non-blocking; it returns a run id immediately.
- On completion, the sub-agent announces a summary/result message back to the requester chat channel.
- For manual spawns, delivery is resilient:
- OpenClaw tries direct
agentdelivery first with a stable idempotency key. - If direct delivery fails, it falls back to queue routing.
- If queue routing is still not available, the announce is retried with a short exponential backoff before final give-up.
- OpenClaw tries direct
- The completion message is a system message and includes:
Result(assistantreply text, or latesttoolResultif the assistant reply is empty)Status(completed successfully/failed/timed out)- compact runtime/token stats
--modeland--thinkingoverride defaults for that specific run.- Use
info/logto inspect details and output after completion. /subagents spawnis one-shot mode (mode: "run"). For persistent thread-bound sessions, usesessions_spawnwiththread: trueandmode: "session".- For ACP harness sessions (Codex, Claude Code, Gemini CLI), use
sessions_spawnwithruntime: "acp"and see ACP Agents.
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.
- Support configurable nesting depth for orchestrator patterns.
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.
Tool
Use sessions_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. - Default thinking: inherits the caller unless you set
agents.defaults.subagents.thinking(or per-agentagents.list[].subagents.thinking); an explicitsessions_spawn.thinkingstill wins. - Default run timeout: if
sessions_spawn.runTimeoutSecondsis omitted, OpenClaw usesagents.defaults.subagents.runTimeoutSecondswhen set; otherwise it falls back to0(no timeout).
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?(defaults toagents.defaults.subagents.runTimeoutSecondswhen set, otherwise0; when set, the sub-agent run is aborted after N seconds)thread?(defaultfalse; whentrue, requests channel thread binding for this sub-agent session)mode?(run|session)- default is
run - if
thread: trueandmodeomitted, default becomessession mode: "session"requiresthread: true
- default is
cleanup?(delete|keep, defaultkeep)
Thread-bound sessions
When thread bindings are enabled for a channel, a sub-agent can stay bound to a thread so follow-up user messages in that thread keep routing to the same sub-agent session.
Thread supporting channels
- Discord (currently the only supported channel): supports persistent thread-bound subagent sessions (
sessions_spawnwiththread: true), manual thread controls (/focus,/unfocus,/agents,/session ttl), and adapter keyschannels.discord.threadBindings.enabled,channels.discord.threadBindings.ttlHours, andchannels.discord.threadBindings.spawnSubagentSessions.
Quick flow:
- Spawn with
sessions_spawnusingthread: true(and optionallymode: "session"). - OpenClaw creates or binds a thread to that session target in the active channel.
- Replies and follow-up messages in that thread route to the bound session.
- Use
/session ttlto inspect/update auto-unfocus TTL. - Use
/unfocusto detach manually.
Manual controls:
/focus <target>binds the current thread (or creates one) to a sub-agent/session target./unfocusremoves the binding for the current bound thread./agentslists active runs and binding state (thread:<id>orunbound)./session ttlonly works for focused bound threads.
Config switches:
- Global default:
session.threadBindings.enabled,session.threadBindings.ttlHours - Channel override and spawn auto-bind keys are adapter-specific. See Thread supporting channels above.
See Configuration Reference and Slash commands for current adapter details.
Allowlist:
agents.list[].subagents.allowAgents: list of agent ids that can be targeted viaagentId(["*"]to allow any). Default: only the requester agent.
Discovery:
- Use
agents_listto see which agent ids are currently allowed forsessions_spawn.
Auto-archive:
- 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.- Auto-archive applies equally to depth-1 and depth-2 sessions.
Nested Sub-Agents
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.
How to enable
{
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)
runTimeoutSeconds: 900, // default timeout for sessions_spawn when omitted (0 = no timeout)
},
},
},
}
Depth levels
| 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 |
Announce chain
Results flow back up the chain:
- Depth-2 worker finishes → announces to its parent (depth-1 orchestrator)
- Depth-1 orchestrator receives the announce, synthesizes results, finishes → announces to main
- Main agent receives the announce and delivers to the user
Each level only sees announces from its direct children.
Tool policy by depth
- Depth 1 (orchestrator, when
maxSpawnDepth >= 2): Getssessions_spawn,subagents,sessions_list,sessions_historyso it can manage its children. Other session/system tools remain denied. - Depth 1 (leaf, when
maxSpawnDepth == 1): No session tools (current default behavior). - Depth 2 (leaf worker): No session tools —
sessions_spawnis always denied at depth 2. Cannot spawn further children.
Per-agent spawn limit
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.
Cascade stop
Stopping a depth-1 orchestrator automatically stops all its depth-2 children:
/stopin 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 allstops all sub-agents for the requester and cascades.
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.
Note: the merge is additive, so main profiles are always available as fallbacks. Fully isolated auth per agent is not supported yet.
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 on channel adapters.
- 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.
Announce payloads include a stats line at the end (even when wrapped):
- 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 and system tools:
sessions_listsessions_historysessions_sendsessions_spawn
When 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"]
},
},
},
}
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, cascading to nested children. /subagents kill <id>stops a specific sub-agent and cascades to its children.
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). - Maximum nesting depth is 5 (
maxSpawnDepthrange: 1–5). Depth 2 is recommended for most use cases. maxChildrenPerAgentcaps active children per session (default: 5, range: 1–20).