Multi-Agent Coordination: Subagents, Worktrees, Reviewers, and Event Logs
Handing one task to several agents is not hard because of how many agents to start. It is hard because of three questions: what each agent can see, what it can change, and who combines the results and verifies them. Claude Code and Codex both ship with subagents, so most individual developers already have them; this page uses them to explain the three boundaries, then borrows from Meta's Muse Code for two further practices, background observers and event logs.
When Several Agents Are Worth It
Start with the cost. In June 2025 Anthropic reported that its multi-agent research system outperformed a single Opus 4 agent by 90.2% on an internal research evaluation, while using about 15 times as many tokens as chats, and that it suits tasks with heavy interdependence less well (post). Codex's subagent documentation likewise states that subagent workflows consume more tokens than comparable single-agent runs.
Review has a cost as well. On the Sonnet 5.5 release page, Anthropic explains that at maximum effort the model more often launched a code review split across many subagents; in two cases Cognition examined, that led to a timeout or to edits beyond the task's scope, and the FrontierCode score fell below the next-lower setting.
In practice, get the task working with one agent first, then split off the parts that are genuinely independent and can be accepted separately, such as reading different documents, investigating problems in different modules, or running unrelated experiments in parallel. Tightly coupled changes, designs that depend on many shared implicit decisions, and repeated reviews tend to get slower and more expensive when split. Compare on the same tasks by completion time, tokens, and rework, not by how many agents ran at once.
Four Roles
Multi-agent systems usually combine four roles: a coordinator splits the task, combines the results, and answers for the final outcome; bounded workers complete only their own piece and return something checkable; background observers take no task of their own and watch one quality dimension, offering suggestions; explicit reviewers examine a result once it is finished.
Claude Code and Codex subagents mostly fill the first two. Background observers are clearest in Muse Code, where four observers for memory recall, skill recall, goal tracking, and verification stay resident for the whole session. They can only advise: "it proposes, a reconciler decides," and only an accepted proposal reaches the main agent's next turn. Review therefore neither interrupts the main agent nor bypasses it to edit code directly.
Three Boundaries to Keep Apart
"Give each subagent its own environment" sounds like one decision. It actually involves at least three separate boundaries:
The first two are the easiest to confuse. Separate contexts do not mean separate files: OpenAI's documentation states that the coordinator and its subagents share one environment's filesystem, and "creating a subagent does not create another environment." Separate files do not mean separate everything, either. According to the Git manual, a worktree keeps only per-worktree files such as HEAD and index to itself and shares the rest of the repository, including the object store and, by default, the repository configuration. Two workers that each start a development server in their own worktree can still fight over one port or write to one test database.
Check where a worktree branches from, too. A Claude Code worktree subagent branches by default from the repository's default branch, not from the parent session's current HEAD. If you are working on a feature branch, the subagent sees the code on the remote main and none of your unpushed changes; to have it continue your feature branch, set worktree.baseRef to "head" in your settings (worktree documentation).
Permissions have a further trap. Claude Code's documentation warns that disabling only Write and Edit does not stop file writes, because Bash remains available. Judge a tool restriction by the effects that remain possible, not by tool names. The wider relationship between permissions, approvals, and sandboxes is covered in Agent Security.
One Bounded Parallel Change
A fictional example: a service needs a new API field, an updated frontend display, and matching documentation, all at once.
- The coordinator fixes the interface first. The field name, type, and default go into every worker's task description. This is the only decision the workers must share, so it has to be settled before assigning work.
- Assign directories by whether a worker writes code. The backend and frontend workers each get a worktree; a worker that only gathers information stays in the shared checkout.
- Workers return evidence, not conclusions. Each returns commits and its own test results, not a statement that it is done.
- The coordinator integrates once and runs one shared acceptance check. Only tests on the merged result catch two halves that each pass but disagree with each other.
- Conflicts go back to the coordinator. If the interface must change, the coordinator decides and reassigns; workers do not edit each other's code.
Among these steps, step 1 deserves the most attention. In June 2025, Cognition argued from examples that parallel agents make implicit decisions that may not fit together, so every action should be "informed by the context of all relevant decisions made by other parts of the system" (post). That is an engineering argument built on cases, not a controlled comparison.
Messages and Cancellation
A message from another agent is data, not an instruction. Muse Code's session messaging treats a received message as "unverified agent-provided data" and does not let it carry the sender's authority.
Cancellation is usually not instantaneous. Muse Code documents it as cooperative: a cancelled subagent that has not reached a checkpoint keeps running, and one in the middle of a write finishes that write. After stopping every agent, check the actual state of the working directories; how a single agent stops together with its subprocesses is covered in Bounded Agent Loops.
What an Event Log Can Recover
Muse Code records every run as an append-only event log covering model calls, tool calls and their results, and approval decisions; after an interruption, the conversation is rebuilt from that log. The log separates two kinds of side effects: those confirmed as complete count as done, while one that was announced but never confirmed requires checking the actual state before deciding whether to retry (audit and resume).
Deterministic replay rebuilds the recorded context from events and "does not call a model, run a tool, or use the network," which suits auditing and regression tests. It cannot make an external side effect happen only once; that still depends on the idempotency keys and state checks described in Long-Running Agents.
Terminal persistence is yet another layer: Herdr restores several agents' terminals after a restart, but does not split tasks, merge results, or isolate working directories.