Skip to main content

Running subagents in parallel without clear boundaries or a shared contract

PhaseSetup & CollaborationRolesArchitect ยท EngineerSeverityHighApplies toAll coding agentsEvidenceOfficial docs

In one sentence: I can delegate in parallel, but context, messages, files, and Git state are separate sharing surfaces. Define contracts, workspaces, and an integrator. Prefer separate worktrees for concurrent writes and one Git writer in a shared workspace.

Symptomโ€‹

You delegate backend, frontend, and tests. Each subagent produces plausible code, but their fields are user_id, userId, and id. Meanwhile one agent switches a shared branch and another commits against the wrong HEAD. File ownership alone did not resolve shared interfaces or Git state.

Why this happensโ€‹

Subagents usually have independent context, not necessarily independent filesystems. Some support messaging or shared tasks; these do not synchronize every assumption automatically. Agents still need explicit inputs, contracts, and handoff artifacts.

One worktree shares HEAD and index. Checking the branch before a commit observes its current state; it does not stop another agent switching it afterward. Separate Git worktrees split HEAD/index and working files, while refs, remotes, and some configuration remain shared. A worktree is not a security sandbox.

Consequencesโ€‹

  • Concurrent edits conflict, interface assumptions diverge, and integration requires rework.
  • An agent stages another agent's files or commits on the wrong branch.
  • Duplicate research, test-environment/port contention, and budget overruns occur; individual completion does not establish integrated success.

What to do insteadโ€‹

Assess independence before choosing how to share.

  1. Read-only research can share a workspace; prefer separate worktrees/checkouts for concurrent writes. In a shared workspace, designate one agent for staging, commits, and branch operations; others must not mutate Git state.
  2. Specify file ownership, allowed tools, input versions, and deliverables. Written scope is not a sandbox; set execution permissions separately. A test agent must not casually change implementation or acceptance criteria.
  3. Agree on interfaces, fields, and error semantics before delegation. An integrator owns shared configuration and types. Send necessary updates through messages; record important decisions in verifiable artifacts.
  4. Limit concurrency, budget, time, and retries without progress. The integrator checks base revisions, resolves conflicts, and runs cross-module validation before reporting completion.
  5. If Git state is wrong, stop concurrent work and preserve diffs and commit identifiers before examining reflogs and branch ownership. Do not force-move or delete branches as a generic recovery step.

Exampleโ€‹

Before:

You: Have three agents build backend, frontend, and tests; combine the results.
Me: They share a directory and Git state, guess interfaces, and commit independently.

After:

Contract: User = { user_id: string; name: string }.
A/B: Separate worktrees for api/ui; C: validate the same contract without changing acceptance criteria.
The integrator owns shared types; only the integrator stages/commits/switches branches in the shared workspace.
Each agent reports base commit, changes, checks, and blockers; run interface regressions after integration.

When the exception appliesโ€‹

Independent read-only research does not need multiple checkouts. Sequential work may be better for tightly coupled tasks, same-module edits, or expensive coordination. Parallelism should not create more delegation and merging than it saves.

Tool differencesโ€‹

As of 2026-10-29, Claude Code, Codex, and Gemini CLI all document native subagents, and Cursor also has related capabilities. Check messaging, inherited context, permissions, and workspace isolation separately. Codex subagents inherit parent safety constraints; naming one โ€œreviewerโ€ does not create a read-only sandbox.

Version notesโ€‹

Verified 2026-10-29

Native delegation, team messaging, and separate workspaces are distinct capabilities. Check the actual product surface. This entry recommends contracts and concurrency boundaries without claiming every agent is unable to communicate or every parallel task must conflict.

Further reading and sourcesโ€‹