On this page
On this page
Agent coordination
Nested sub-agents and authentication
Nested sub-agents
By default, sub-agents can recursively delegate through depth 5. Per-session
execution and child admission limits, inherited tool policy, sandbox
inheritance, and target-agent allowlists still apply. Set a lower depth to
create leaf workers sooner.
Depth levels
| Depth | Session key shape | Default role | Can spawn? |
|---|---|---|---|
| 0 | agent:<id>:main |
Main agent | Always |
| 1 | agent:<id>:subagent:<uuid> |
Orchestrator | Yes, unless maxSpawnDepth: 1 |
| 2-4 | Persisted flat sub-agent keys with lineage | Orchestrator | Yes, by default |
| 5 | Persisted flat sub-agent key with lineage | Leaf | No, at the default boundary |
Announce chain
Results flow back one level at a time:
- A descendant finishes and announces to its direct parent.
- That parent synthesizes its children before finishing and announcing upward.
- The main agent receives the final announce and delivers to the user.
Each level only sees announces from its direct children.
Tool policy by depth
- A child captures the requester's effective sender policy when it is spawned. Senderless child runs and authenticated operator resumes keep that snapshot even if
toolsBySenderchanges later; current global, agent, provider, sandbox, and sub-agent restrictions still apply. A new external channel turn targeting the child re-resolves current sender policy instead. - Role and control scope are written into session metadata at spawn time for provenance. The current depth policy is authoritative, so existing sessions gain or lose recursive orchestration tools when the configured cap changes.
- Orchestrator (below
maxSpawnDepth): getssessions_spawn,subagents,sessions_list,sessions_historyso it can spawn children and inspect their status. Other session/system tools remain denied. - Leaf (at
maxSpawnDepth): no recursive orchestration tools.
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. Separately, maxConcurrent limits executing child
runs for that immediate spawning session. Each nested orchestrator gets its own
execution budget; its children do not share the root session's slots.
Reset a conversation
A full in-place conversation reset cancels unfinished native subagents associated with that session, including yielded children and children whose completion requester differs from their controller. Chat /reset and sessions.reset use the same cleanup owner. If child cancellation is incomplete, reset reports a failure before clearing the conversation; inspect the remaining tasks and retry. Child transcripts and unrelated sessions are preserved.
Completed subagent history does not block reset. Completed children still participate in cleanup when they retain commands, pending completion wakes, controller disposal, or unfinished descendants.
Cascade stop
Explicit cancellation of an orchestrator cascades through its descendant
tree. A Stop cancels the children of every run it stops: Esc in the TUI, Stop
in a connected app and an exact-run Stop stop the children of the stopped
turn, while children that an earlier, finished turn started keep running.
/stop in the main chat and sessions.abort stop the session's whole child
tree.
See Stopping for scope and incomplete-cancellation behavior.
Authentication
Sub-agent auth is resolved by agent id, not by session type:
- The sub-agent session key is
agent:<agentId>:subagent:<uuid>. - The local auth overlay is loaded from that agent's
agentDir. - The shared auth profiles are merged in as a fallback; agent profiles override shared profiles on conflicts.
The merge is additive, so shared profiles are always available as fallbacks. There is no setting that isolates an agent's auth from the shared profiles.
A child does not inherit its parent's selected account. See Defaults.
Memory audience inheritance
OpenClaw sessions_spawn (including ACP runtimes) and realtime voice consults
record the immediate parent key (spawnedBy), exact parent session id
(spawnedBySessionId), parent lifecycle revision
(parentSessionLifecycleRevision), and the spawning invocation's trusted owner
status (spawnedBySenderIsOwner). These are host-owned facts, not tool arguments
or sessions.patch fields. The owner flag is never inferred from a child's
synthetic launch authority; voice consults take it only from the caller's
ingress authentication. Missing or false owner status does not grant owner
access.
For memory access, OpenClaw checks that every recorded parent still exists and was not recreated or assigned to another owner after its child was created. A parent reset keeps the parent's session and owner, so its children keep their memory audience and resolve it against the parent's current incarnation. It then supplies the host-minted root audience to memory providers and plugin tools. Providers must consume that prepared audience and must not walk session lineage or infer memory authority from session lookups.
A reset or removal of any recorded parent invalidates an already captured audience, so the next protected provider or tool operation fails its audience currency check. The child's next turn resolves a new audience. When a parent was removed, recreated, or assigned to another owner after the spawn, later turns of that child receive no memory audience, and with a native memory provider the Gateway log warns that the child's lineage is stale and that it must be respawned from a current session. Legacy children without the complete lineage stamps receive no inherited memory audience: their turns run without private or conversation memory, and the Gateway log warns that the session predates memory lineage receipts and must be respawned from its parent.
A child spawned into a different agent inherits only the owner's private
audience, applied to the child agent's own memory, and only when an owner turn
spawned it from the owner's direct chat. The spawn already requires the target to
be allowed by subagents.allowAgents and the requester's operator role. Children
of group, channel, or non-owner conversations in another agent receive no memory
audience.
This contract covers OpenClaw-created child sessions. Native runtime child threads also need their runtime's tool bridge to provide a live authorized invocation; lineage metadata alone does not add that bridge.