# Agent collaboration compared

How does one agent delegate to another, and can it still control that work? Our design: [Agent collaboration](https://fzkuji.github.io/OpenProgram/docs/reference/design/runtime/collaboration/agent-collaboration.html); our tool surface: [architecture](https://fzkuji.github.io/OpenProgram/docs/reference/design/runtime/collaboration/agent-collab-architecture.html).

**How this was checked**

Seven repositories were read directly, with file paths and line numbers. Claude Code findings come only from its [public documentation](https://code.claude.com/docs/en/overview); a mechanism it does not describe reads “Undocumented”. For the other systems, an empty or “none” entry means the mechanism is absent, not unchecked.

## Overview

| System | Spawning | Direct messages | Tracking | Cascading cancel |
| --- | --- | --- | --- | --- |
| Ours | In-process; depth optional | Any to any | `execution_id`, two tools | Yes |
| Claude Code | Within the session, depth 3 | Yes, across machines | `agentId`, `ListAgents`, `TaskStop` | Undocumented |
| codex-cli | In-process; V1 depth 1, V2 unlimited | Yes, siblings | ThreadId, four tools | Partial |
| openclaw | In-process or external, depth 1 | Yes, if enabled | runId, list only | Yes |
| opencode | In-process, implicit depth 1 | No | Child session id | Yes |
| hermes-agent | In-process pool, depth 1 | Not in the tree; through the board | None for the model | Yes |
| pi-mono | Child process, unlimited | No | None | One level |
| pi-ai | None | None | None | Not applicable |
| weclaw | None | No | None | Not applicable |

| System | Loop controls | Tool restriction | Addressing | Lines |
| --- | --- | --- | --- | --- |
| Ours | 4 on, 3 optional | Remove by remaining allowance | Branch name or `SID:HEAD` | 9.3k |
| Claude Code | 7 | Withheld at the depth limit; a fork gets an error at call | Name or agent ID | Undocumented |
| codex-cli | 2 | Remove; V1 also rejects | Path, `/root/x` | 7k |
| openclaw | 8 | Remove, recheck at spawn | Session key | 17k |
| opencode | 3 | Remove or reject, by rule shape | Agent type name | 0.4k |
| hermes-agent | 5 | Remove whole toolsets | Anonymous, one-shot | 2.9k |
| pi-mono | 2 | Remove by allowlist | Name of an on-disk `.md` | 1.3k |
| pi-ai | None | Not applicable | None | 0 |
| weclaw | 1 | Not applicable | `@name` | 1.1k |

## Spawning children

| System | Runs as | Depth limit and where it is enforced |
| --- | --- | --- |
| Ours: `agent` | In-process pool, 8 workers by default; 6 running per conversation, the rest queued | `agent.max_spawn_depth`, 1 by default; past it, “do the work yourself”. `agent.max_spawn_fanout` per turn, off by default. |
| Claude Code: `Agent`, formerly `Task` | Subagents in the session, optionally `isolation: worktree`; teammates in-process or in tmux or iTerm2 panes | Depth 3 by default, set by `CLAUDE_CODE_MAX_SUBAGENT_SPAWN_DEPTH`; concurrency 20 by default, set by `CLAUDE_CODE_MAX_CONCURRENT_SUBAGENTS`. |
| codex-cli: `spawn_agent` | Tokio tasks on one thread manager | V1 depth 1. V2 computes child depth and never checks it; disabled by default; only concurrency caps it. |
| openclaw: `sessions_spawn` | `subagent` in-process; `acp` external host process, off in sandboxes | Depth 1, up to 5, counted from `:subagent:` segments of the session key |
| opencode: `task` | Re-enters the prompt loop in a child session | No number. A `task: * deny` rule removes the tool from the child, giving depth 1; an agent declaring `permission.task=allow` is unlimited. |
| hermes-agent: `delegate_task` | Thread pool; external ACP CLI; one process per board card | `MAX_DEPTH=1`, clamped to 1–3 |
| pi-mono: example extension; core omits it | One new `pi --mode json -p --no-session` per child | None. Children reload the extension, and `worker` declares no allowlist, so recursion is unbounded. |
| pi-ai | Read-only snapshot of pi-mono's LLM transport; neither compiled nor imported | Not applicable |
| weclaw | Starts user-configured agent CLIs as top-level agents | No nesting |

Subprocess paths give isolation, not depth control.

**Code locations**

| System | Location |
| --- | --- |
| Ours | `programs/tools/agents/agent/agent/agent.py; defaults in state/settings.py` |
| Claude Code | Public documentation: [Subagents](https://code.claude.com/docs/en/sub-agents) |
| codex-cli | `core/src/config/mod.rs:284; V1 check handlers/multi_agents/spawn.rs:65-71; V2 calculation multi_agents_v2/spawn.rs:62` |
| openclaw | `config/agent-limits.ts:8; check agents/subagent-spawn.ts:784-791` |
| opencode | `tool/task.ts:133-135; agent/subagent-permissions.ts:18,25` |
| hermes-agent | `tools/delegate_tool.py:133,136-137; check :1958-1972` |
| pi-mono | `README.md:476 "No sub-agents"; examples/extensions/subagent/index.ts:329-333; agents/worker.md:1-5` |
| pi-ai | `README.md:1-19` |
| weclaw | `agent/cli_agent.go:140,159; four-method interface agent/agent.go:79-95` |

## Direct communication

- **No channel**: weclaw, pi-ai
- **Through the parent**: opencode, pi-mono, hermes-agent
- **Direct**: Ours, Claude Code, codex-cli, openclaw

| System | Connection and delivery |
| --- | --- |
| Ours | `send_message(to=)` from any agent to any unarchived branch, same path across sessions, no ownership check. Busy targets queue in the session inbox. |
| Claude Code | `SendMessage`. `to`: teammate or subagent name, `main`, an agent ID, or another session’s name; a local session’s inbox address starts with `uds:`. No broadcast: one message per recipient. Teammates use file mailboxes `~/.claude/teams/{team}/inboxes/{name}.json`. Sending to a finished subagent resumes it. |
| codex-cli | `send_message`, `followup_task`, straight to the target thread. Absolute paths let siblings address each other. Delivery queues, or wakes the recipient for one turn. |
| openclaw | `sessions_send`, off by default: a config switch and pairwise allowlist. A bounded back-and-forth loop. Children cannot use it and return through the parent's announcement queue. |
| opencode | Parent to child only, which may append to a running child. No messaging tool in the registry. |
| hermes-agent | Children report to parents only; `send_message` is on the never-for-children list. Board workers, one process per card, exchange card comments in a shared database; the root card holds a conventional shared area. |
| pi-mono | One prompt at spawn, stdout on exit. Sequential mode substitutes the previous output into the next task, the only sibling channel. |
| pi-ai | No agents |
| weclaw | `@a @b message` sends one message to several agents, each replying to the human with a prefix. Agents cannot see each other. |

Beyond one process: Claude Code reaches other local sessions and machines, ours any session, openclaw by session key.

**Code locations**

| System | Location |
| --- | --- |
| Ours | `programs/tools/agents/send_message/send_message/send_message.py; addressing.py; runtime/conversation/peer_agents/inbox.py` |
| Claude Code | Public documentation: [Agent teams](https://code.claude.com/docs/en/agent-teams), [Cross-session messaging](https://code.claude.com/docs/en/cross-session-messaging) |
| codex-cli | `handlers/multi_agents_v2/message_tool.rs:11-24,51-131; absolute paths protocol/src/agent_path.rs:59-71; delivery core/src/agent/control.rs:171` |
| openclaw | `agents/tools/sessions-send-tool.ts:193,249-256; back-and-forth sessions-send-tool.a2a.ts:94; child restriction agents/pi-tools.policy.ts:49-50` |
| opencode | `tool/registry.ts:217-236 (whole built-in registry); parent-to-child tool/task.ts:242-257` |
| hermes-agent | `denylist tools/delegate_tool.py:50; board toolsets.py:252-269; shared area hermes_cli/kanban_swarm.py:11-14,26,226-268` |
| pi-mono | `examples/extensions/subagent/index.ts:530,569; parallel isolation :618-639` |
| weclaw | `messaging/handler.go:456-486; command registry (7 entries) :686-698` |

## Tracking and cancellation

| System | Id to the model | Status | Result returns | Model cancels | Cascade |
| --- | --- | --- | --- | --- | --- |
| Ours | `j_` prefix | `list_agents`, `read_conversation` | Completion notice in the dispatcher's conversation, one result shape | `close_agent`; UI or API `execution.cancel` | Yes, breadth-first over `parent_job_id`, visited set |
| Claude Code | `agentId` | `ListAgents`; `/tasks` | Returned to the caller on completion; background tasks are read from their output file | `TaskStop` | Undocumented |
| codex-cli | ThreadId and path | `list_agents`, `get_status`, push subscriptions | Monitor synthesizes a parent message; `wait_agent`, default 30 s, at most 1 h | `interrupt_agent`; V1 `close_agent` | `close_agent` cascades, `interrupt_agent` stops one; V2 has only the latter |
| openclaw | runId | `subagents`, list only | Pushed: `sessions_yield` ends the turn, result arrives next | No; `/subagents kill`, HTTP endpoint | Yes, recursive; each child clears its queue and writes an abort marker |
| opencode | Child session id, reusable to resume | No; the prompt forbids polling | Tool result, or a synthetic parent message | No; host-side | Yes, abort signals and metadata traversal to a fixed point; deletion too |
| hermes-agent | No; index, status, summary, usage | Gateway RPC | Blocking, all together | Gateway RPC | Yes, cooperative, no thread kill |
| pi-mono | No; id discarded | No; UI callbacks | Child stdout, final text, 50KB per task | Environment abort only | One level: SIGTERM, SIGKILL after 5 s; children not in cleanup registry, so a forced kill orphans them |
| pi-ai | None | None | None | None | One flat abort per HTTP request |
| weclaw | None | None | Synchronous, by WeChat user id | No | No hierarchy; global cancel at shutdown |

Cascading systems walk parent links with a visited set; they differ in walking memory or durable records.

**Code locations**

| System | Location |
| --- | --- |
| Ours | `runtime/jobs/runner/cancellation.py; return runtime/jobs/notices.py; ownership programs/tools/agents/agent/_ownership.py` |
| Claude Code | Undocumented |
| codex-cli | `cascade core/src/agent/control/legacy.rs:86-101, descendants control.rs:732-756; non-cascade control.rs:247-257` |
| openclaw | `agents/subagent-control.ts:205,232,238,256; kill auto-reply/reply/commands-subagents/action-kill.ts:27` |
| opencode | `session/run-state.ts:116-148; tool/task.ts:296-306; tests test/tool/task.test.ts:870` |
| hermes-agent | `result fields tools/delegate_tool.py:1684-1720; recursion run_agent.py:1690-1730` |
| pi-mono | `discarded id examples/extensions/subagent/index.ts:466; termination :393-403; compare src/utils/shell.ts:172` |
| weclaw | `messaging/handler.go:541-556; command registry :686-698` |

## Loop prevention

| System | Controls |
| --- | --- |
| Ours | On: 4 concurrent, inbox 50 with oldest evicted, 60 s duplicate window, self-delivery rejected. Optional, off by default: depth, per-chain messages, per-turn fan-out. No tool-round cap on chat turns. |
| Claude Code | Depth 3 and concurrency 20 by default, no total spawn cap; a fork cannot fork; teammates cannot spawn teammates. Cross-session messages: rate-limited per sender, identical repeats dropped within a short window, at most 50 queued. |
| codex-cli | Depth (V1 1, V2 none); concurrency 6 global, 4 per V2 session. No dedup, count, rate limit or cycle detection, so with sibling addressing nothing stops two agents delegating forever. |
| openclaw | Depth 1 (to 5); 5 children per agent (to 20); concurrency 8 and 4; conversations 5 rounds (to 20); 2 s steering limit; 3 announcement retries; child-key dedup; tool-loop detector, off by default. |
| opencode | Depth by injected permission. Same tool with identical arguments 3 times prompts for permission. Steps unlimited by default. |
| hermes-agent | Depth 1 (to 3); 3 concurrent; 50 iterations per child; 600 s timeout plus heartbeat; a global spawn pause; delegation toolset removed from leaves. No dedup or count. |
| pi-mono | Fan-out 8, concurrency 4, 50KB output per task. No depth, dedup, rate or round cap; recursion is unbounded. |
| pi-ai | No tool loop |
| weclaw | Dedup: WeChat ids for 5 minutes, names within a broadcast. No return channel, so no cycles. |

Depth limits are nearly universal; only three systems count messages.

**Code locations**

| System | Location |
| --- | --- |
| Ours | `programs/tools/agents/send_message/send_message/depth.py; programs/tools/agents/agent/agent/agent.py; runtime/conversation/peer_agents/inbox.py; self-delivery guard send_message.py` |
| Claude Code | Public documentation: [Subagents](https://code.claude.com/docs/en/sub-agents), [Agent teams](https://code.claude.com/docs/en/agent-teams), [Cross-session messaging](https://code.claude.com/docs/en/cross-session-messaging) |
| codex-cli | `core/src/config/mod.rs:212-213,284; concurrency core/src/agent/control/execution.rs:68-76` |
| openclaw | `config/agent-limits.ts:3-8; rounds agents/tools/sessions-send-helpers.ts:15-16; rate limit agents/subagent-control.ts:45,507-516; retries agents/subagent-registry-helpers.ts:35` |
| opencode | `DOOM_LOOP_THRESHOLD=3 session/processor.ts:35, check :519-546; steps session/prompt.ts:1281` |
| hermes-agent | `tools/delegate_tool.py:132-133,136-137,512-523; pause switch :149-172; toolset removal :672-680` |
| pi-mono | `examples/extensions/subagent/index.ts:27-30; main loop packages/agent/src/agent-loop.ts:170` |
| weclaw | `messaging/handler.go:273,63-64; name deduplication :246-253` |

## Restricting child tools

- **A: remove from the list**: The model never sees it. Definitions differ by level, so prompt caches split.
- **B: keep, reject at call**: Definitions stay byte-identical and caches hit. An attempted call wastes a turn.

| System | Approach | What and when |
| --- | --- | --- |
| Ours | A by remaining allowance, then refusal | Only `agent`, only when the message budget is out (`delegation_budget_left`), since every dispatch costs a message. Spent generations do not remove it: work can still go to existing agents. Everything else stays. Deliberately binary: a per-level set would shred the prompt cache. |
| Claude Code | A and B | `Agent` is withheld at the depth limit; a fork keeps it and gets an error at call. |
| codex-cli | V1 A+B, V2 A | Tool list omits collaboration tools at the limit; V1 handlers also reject. Roles overlay configuration files, not allowlists. |
| openclaw | A+B | All children lose gateway, agent listing, session status, scheduled tasks and cross-agent messaging. Leaves also lose subagent listing, session listing, history and spawning. Spawn rechecks depth. |
| opencode | A or B | Deny with `"*"` removes from the schema; a specific pattern keeps it and throws at call, returning the matched rule. |
| hermes-agent | A, per toolset | Requested ∩ parent-owned, minus delegation, user-question, memory and code execution. Gap: the never-for-children list only generates docs, so a child inheriting the messaging set still gets `send_message`. |
| pi-mono | A | Allowlist becomes child arguments; the child filters its registry and rebuilds its prompt. |
| pi-ai | Not applicable | No tool executor |
| weclaw | Not applicable | Tools are opaque inside the wrapped CLI |

**Code locations**

| System | Location |
| --- | --- |
| Ours | `programs/tools/agents/send_message/send_message/depth.py delegation_budget_left; can_use on programs/tools/agents/agent/agent/agent.py` |
| Claude Code | Public documentation: [Subagents](https://code.claude.com/docs/en/sub-agents) |
| codex-cli | `core/src/tools/spec_plan.rs:561-572,1099; V1 rejection handlers/multi_agents/spawn.rs:67-71; roles core/src/agent/role.rs:37,249` |
| openclaw | `agents/pi-tools.policy.ts:42-51,57-62,170-175; recheck agents/subagent-spawn.ts:786` |
| opencode | `removal permission/index.ts:215-225, session/llm/request.ts:198-204; rejection permission/index.ts:86-90, message packages/core/src/v1/permission.ts:84-90` |
| hermes-agent | `tools/delegate_tool.py:945-961,672-680; list :45-53; gap compared with toolsets.py:190` |
| pi-mono | `core/agent-session.ts:2253-2342; allowlist core/sdk.ts:280-286; arguments examples/extensions/subagent/index.ts:290` |
| weclaw | `the only tool mention, for display: agent/acp_agent.go:139` |

## Identity and addressing

| System | Named | Finding existing agents | Address |
| --- | --- | --- | --- |
| Ours | Yes: about 24-character placeholder, then LLM titles at turns 1, 6, 16, 40 | `list_agents`: session, all, archived; each with address, turns, size, preview | `SID:HEAD`, name or unique prefix; resolves to the tip, so old heads stay valid |
| Claude Code | Names for subagents and teammates; `main` is the main conversation | `ListAgents`: subagents, teammates, local sessions; cloud and other-machine sessions while connected to Remote Control | Name, `main`, agent ID; when local names collide, the identifier from the listing |
| codex-cli | Path from `/root`; nicknames from 101 scientists | `list_agents` by path prefix; live children also in environment context | Path or ThreadId |
| openclaw | Yes, in configuration files | `agents_list`, removed from children | `agent:<id>:…:subagent:…`, or label plus agentId |
| opencode | Types, not instances | Names in the `task` description; running agents undiscoverable; ids only reconnect one's own child | Bare name |
| hermes-agent | Anonymous, one-shot | No tool; internal `sa-index-random` ids are operations-only | None; board cards use profile names |
| pi-mono | On-disk definitions, not processes | Rescans the directory; children leave nothing | Name by linear scan; learned from error messages |
| pi-ai | None | None | None |
| weclaw | Config keys and aliases | No tool; `/info` is a human command | `@name` or `/name` |

**Code locations**

| System | Location |
| --- | --- |
| Ours | `programs/tools/agents/send_message/list_agents/list_agents.py; programs/tools/agents/send_message/send_message/addressing.py; runtime/conversation/turn_runtime/titles.py` |
| Claude Code | Public documentation: [Cross-session messaging](https://code.claude.com/docs/en/cross-session-messaging), [Tools reference](https://code.claude.com/docs/en/tools-reference) |
| codex-cli | `protocol/src/agent_path.rs:15-19,54-71,129-146; names core/src/agent/agent_names.txt; listing core/src/agent/control.rs:383-395,361-381` |
| openclaw | `sessions/session-key-utils.ts:108-126; agents-list-tool.ts:37; child restriction pi-tools.policy.ts:45` |
| opencode | `tool/task.ts:46,116; names tool/registry.ts:252-265; definitions agent/agent.ts:35-55` |
| hermes-agent | `parameters tools/delegate_tool.py:2675-2751; internal id :920-922; board hermes_cli/kanban_db.py:5674-5679` |
| pi-mono | `examples/extensions/subagent/agents.ts:52-56,97-116; arguments index.ts:288; parsing index.ts:272-286` |
| weclaw | `config/config.go:16-33; parsing messaging/handler.go:206-265; aliases :169,187` |

### Code size

| System and lines | Measured |
| --- | --- |
| openclaw, 17,240 | 73 non-test TypeScript files, including UI commands and registries |
| Ours, about 9,300 | Agent tools 2,526; jobs package without resource governance 5,541; inbox 511; `sub_agent_run` 750 |
| codex-cli, 7,059 | Multi-agent core; plus 3,676 supporting and 13,114 test lines |
| hermes-agent, 2,900 | Delegation; plus about 1,600 for the Kanban path |
| pi-mono, 1,310 | Whole example extension; the mechanism is about 190 |
| weclaw, 1,050 | All agent code; routing core about 150 |
| opencode, 415 | Delegation; plus about 365 of reused background-task code |
| pi-ai, 0 | No implementation |

Boundaries differ; compare orders of magnitude only. Tests excluded.

## What we took from this

| Domain | Tools | Holds |
| --- | --- | --- |
| Plan | `task_start`, `task_step`, `task_list` | A named task and its steps; editing runs nothing |
| Execution | `read_conversation`, `close_agent` | One id, one status, guaranteed return, cascading cancel |
| Entity | `agent`, `list_agents`, `send_message` | An agent is a branch in the session graph |
| Communication | `send_message`, `read_conversation` | Messages without task records; any branch's transcript |

| Choice | Against | Why |
| --- | --- | --- |
| Tool names `agent`, `list_agents`, `send_message` | Claude Code | Models already know them |
| Planning is `todo_*` | Differs from Claude Code | Its `TaskList` is a plan board; ours keeps running work and plans apart |
| Address a branch, not a process | Like codex-cli paths, openclaw keys | (session, head) identifies it without an agent table |
| Any agent may message any agent | Looser than openclaw; like codex-cli V2, Claude Code | A message makes no task and cannot cascade; the worst outcome is silence |
| One message tool: `send_message` always makes a Job | Codex `send_input`, Claude Code `SendMessage` | Return, cancel and cascade belong to Jobs; one tool removes the choice between three addressing forms |
| Per-chain message budget; 8 when set, counting return flow | Only openclaw also counts | Depth alone cannot stop existing agents delegating to each other. 8 sits between openclaw's 5 and 20 because we also charge spawns and dispatches. A return rebinds the count, so one round trip costs 1; generations restore to the dispatcher's, so a coordinator can dispatch the next batch. |
| Depth 1 when set, not 3 | openclaw, codex-cli V1, hermes, opencode | Depth 3 suits nesting with a human watching. Our unattended path is `run_in_background=True`. |
| Per-turn fan-out; 8 when set | Only openclaw has a true fan-out cap | A spawn leaves the parent's counters alone, so neither chain counter sees siblings. openclaw's 5 live children (1–20) is the reusable unit; hermes's 3 and pi-mono's 8 are batch arguments and `agent` makes one child. 8 is two pool widths: fill it, queue a batch, then refuse the ninth and name the existing eight. |
| No steering rate limit or child hard timeout | openclaw 2 s; hermes 600 s | openclaw's limit guards steer, which aborts the child's turn; ours queues and interrupts nothing. Hermes's timeout is a caller-side wait that abandons the thread. `job_output(timeout=)` is that wait, and `execution.cancel` also terminates the runtime and forces a terminal state after 30 s. |
| Remove tools by allowance, binary | Others remove always or by depth tier | Tiers invalidate prompt caches |
| Extra tools `close_agent`, `read_conversation` | Codex `close_agent`; Claude Code `TaskStop` | Stop and retire a helper in one call, read history without raw session files |

Rationale for each number sits beside its constant. Limits ship off, so the job pool bounds concurrency and the owner chooses depth. Open gaps: [implementation status](https://fzkuji.github.io/OpenProgram/docs/reference/design/runtime/collaboration/agent-collaboration.html#implementation-status).
