> For the complete documentation index, see [llms.txt](https://www.openclawbook.xyz/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://www.openclawbook.xyz/en/ch09-multi-agent-in-practice/9.2-subagents-and-cross-agent-communication.md). Agents can also search and read this documentation through its [MCP server](https://www.openclawbook.xyz/~gitbook/mcp).

# 9.2 Subagents and Cross-Agent Communication

> **Generated by**: Claude Opus 5 (claude-opus-5\[1m]) **Token usage**: Input \~178,000 tokens, Output \~9,000 tokens (this section) **Source baseline**: `v2026.3.9` (`v2026.3.8-170-g665f67726`)

***

## 9.2.1 Spawning Subagents

An agent can spawn subagents to work in parallel, using the `sessions_spawn` tool.

You don't invoke it directly — you describe work that benefits from parallelism:

```
Review these four files independently and report the issues in each
```

The agent may spawn four subagents, each reading one file, and collect their reports.

### When it helps and when it doesn't

| Good fit                                                                  | Poor fit                                                  |
| ------------------------------------------------------------------------- | --------------------------------------------------------- |
| Independent parallel work (review N files, research N topics)             | Sequential work where each step needs the previous result |
| Work needing a clean context (a subagent doesn't carry your conversation) | Anything needing the full conversation context            |
| Isolating a risky operation                                               | Quick tasks — spawn overhead exceeds the work             |

**Subagents get a minimal bootstrap set** — no `MEMORY.md` (§28.5.2). That's deliberate for privacy and token cost, but it means **a subagent doesn't know what you told the parent.** Everything it needs must be in the task description.

### Depth limits

Subagents can spawn subagents, but only to a configured depth (§39.4.2).

That limit exists to prevent a **fork bomb**: a prompt saying "break this down and delegate to subagents," if inherited by each subagent, recurses indefinitely — burning tokens at every level. The depth cap is what stops it.

### Watching them

```
/subagents          # list running subagents
```

Or through the tool: the agent can list and terminate them itself.

### Do not ask it to poll

An important behavior worth understanding: **completion is push-based.** When a subagent finishes, its result is injected into the parent session automatically.

The system prompt explicitly forbids the agent from polling (`sessions_list`, `exec sleep`, and so on) — because **every poll is a full LLM turn**, and ten polls can cost more than the subtask itself (§39.4.2).

If you see the agent polling anyway, that's worth reporting as a prompt-adherence issue.

## 9.2.2 Cross-Agent Messaging

Agents can send messages to each other's sessions with `sessions_send`.

```
Ask the research agent to look into this and report back
```

### How it works

```
Agent A calls sessions_send targeting Agent B's session
        ↓
The message is injected into B's session as a user message
        ↓
B processes it and can reply through sessions_send back to A
```

**The injection channel is the same one used by subagent completion notifications and by steering** (§39.4.4) — all three are "push a user message into a running session," differing only in origin.

### Visibility constraints

Cross-session access is constrained by policy (`sessions-access.ts`) — an agent can't arbitrarily read any session it likes. Which sessions are visible depends on configuration.

**Worth checking if you're running agents at different trust levels.** A public-facing agent being able to read your private agent's history would defeat the separation you set up in §9.1.

## 9.2.3 Agent Scope and Isolation

### What's isolated

| Isolated                        | Shared              |
| ------------------------------- | ------------------- |
| Workspace (personality, memory) | The gateway process |
| Auth profiles and credentials   | The machine         |
| Session storage                 | Config file         |
| Model and tool policy           | Plugins             |

**Note the right column.** Agents are isolated at the configuration level, **not at the process or OS level**. They share a process, and a plugin loaded for one is loaded for all (§21.5.6).

> **So agent separation is about organization and blast radius, not security isolation.** If you need genuine isolation — mutually untrusted users, say — the answer per §44.4 is separate machines, not separate agents.

### What subagents inherit

A subagent runs under its parent agent's configuration: same model chain (unless overridden), same tool policy, same credentials. It gets a **clean session**, not a different identity.

If you want a subagent with genuinely narrower capability, the mechanism is the **sandbox tool policy** (§22.5.1's layer six) rather than agent separation.

### ACP: a boundary worth knowing

An agent can also delegate to an **external ACP agent** (Claude Code, for instance) rather than a subagent.

But there's a hard rule (§39.4.3):

```
ACP runs on the host machine
  → a sandboxed session may not spawn ACP
  → sandbox="require" has no effect on the ACP path
```

Meaning: if you're relying on sandboxing, **delegating to ACP would escape it** — so it's forbidden rather than silently permitted.

The `sandbox="require"` clause is stated as explicitly ineffective rather than best-effort, so callers can't believe they're protected when they aren't. That's the §44.4 posture applied concretely: **better to say plainly there's no protection than to offer a switch that looks effective.**

***

## Section Summary

1. **Subagents suit independent parallel work and tasks needing a clean context**; they're poor for sequential work and quick tasks where spawn overhead dominates.
2. **Subagents don't get `MEMORY.md`** — deliberate for privacy and cost, but it means **everything they need must be in the task description**.
3. **Depth limits prevent fork bombs** — a "delegate to subagents" prompt inherited by each subagent would recurse indefinitely.
4. **Completion is push-based and polling is explicitly forbidden** — every poll is a full LLM turn, and ten can cost more than the subtask.
5. **Cross-agent messaging, subagent completion, and steering all share one injection channel** — pushing a user message into a running session; only the origin differs.
6. **Agents are isolated at the configuration level, not the process or OS level** — they share a process and plugins. **Separation is about organization and blast radius, not security isolation**; genuine isolation means separate machines.
7. **A sandboxed session may not spawn ACP**, and `sandbox="require"` is **explicitly ineffective** there rather than best-effort — better to say plainly there's no protection than to offer a switch that looks effective.
