Quanta

← Back to Briefings

Four Worktrees, One Balance: A Six-Agent Parallel Run

Coding agents at scaleEN57 reads

01 · Six agents, one repository, one rollout week

The pattern shows up the same way on almost every heavy engineering team: a rollout week arrives, the backlog splits into six independent-looking slices, and someone suggests running several coding agents at the same time instead of queueing them. On paper the slices are independent. In practice, a single shared checkout turns them into one destructive workspace. An agent that runs a formatter touches files a second agent is editing. A third agent reverts an unstaged change it does not recognize. A fourth holds the index lock during a long commit. The work that was supposed to save wall-clock time spends most of it reconciling chaos.

The head-to-head here is simple to state and expensive to get wrong. On one side: one working directory, several agents, and a human acting as a traffic controller. On the other side: one git worktree per agent, each on its own branch, each with its own index and its own command shell. The second arrangement is the only one that survives contact with a real team schedule, but it pushes the coordination problem somewhere else, into token spend, merge order and model choice. This breakdown walks through all three under the assumptions of a team that runs sustained workloads and watches a meter.

02 · One worktree per agent, and what each agent actually owns

A git worktree is a second checkout of the same repository, attached to its own branch, sharing object storage with the main clone. That last part matters more than it sounds: the agents are not duplicating history, and switching between them is instant. What is not shared is the working tree, the index and the local untracked files. That boundary is exactly what parallel agents need. Each agent can run a build, regenerate a lockfile, drop scratch notes into a scratch directory or leave an unfinished half-refactor on disk without leaking any of it into a sibling task.

  • › Name branches after tasks, not agents. A branch named after the slice tells the reviewer what is supposed to be true after the merge, and survives agent restarts without re-labeling.
  • › Give every worktree its own build and test sandbox. Dependency installs cost disk, but shared caches across worktrees reintroduce the interference the worktrees were meant to remove.
  • › Keep hooks deliberate. If a pre-commit hook runs a full test suite, six agents will hold six suites open at once. Decide whether that is acceptable before the first run, not during it.
  • › Prune aggressively. Merged worktrees should be removed in the same session that merges them. Stale worktrees are the main way teams end up editing code that no longer exists on the trunk.

Ownership is the win. Once each agent has a directory that is unambiguously its own, the only remaining shared resources are the review process, the merge queue and the budget.

03 · Context cost head-to-head: shared preamble against per-worktree briefs

Parallel agents are not six times the cost of one agent, but they are rarely the cost of one agent either. The largest lever is the shape of what every agent has to read before it can start. Six agents given the same long repository briefing will each ingest it, and each will ingest it again on every context rebuild. Six agents given a shared, stable instruction prefix plus a short task brief read far less, and the stable prefix is the part a caching-friendly setup can reuse.

This is where metering discipline pays off directly. On a relay such as Quanta, every call is metered on real tokens, with cache writes and cache reads priced separately, so the difference between a prompt that stays byte-identical across turns and one that gets lightly reworded at the top of every message is a real budget difference across a sustained workload. The practical rules follow from that. Put the invariant material first, in a fixed order. Keep task-specific detail at the end. Do not let an agent re-summarize the whole plan on every turn just to restate it. Long-running agents in a single worktree, doing a multi-hour refactor, are the ones that benefit most from a warm cache; short probe runs that ask three questions and exit are the ones that spend cache writes and get very little back.

Head-to-head, a shared checkout with one agent reads less but stalls more, while the worktree arrangement reads more but finishes earlier. For a team that cares about both wall-clock time and a metered balance, the second wins as long as the prompt layout is treated as an engineering artifact rather than something each agent improvises.

04 · Model mix head-to-head: one heavy refactor, five fast loops

Not every worktree deserves the same model. The useful split is by the cost of a wrong turn. The worktree holding a cross-cutting refactor, where an early mistake compounds into dozens of downstream edits, wants the most capable reasoning available; Claude Sonnet 5.5 is the kind of assignment that fits there. The worktrees holding mechanical edits, test fixes and a review sweep over a long diff want speed and low latency per iteration; Claude Haiku 4.5 handles that loop well and keeps the metered spend proportional to the work.

  • › Assign the model per worktree, at the start. Swapping models mid-task loses the reasoning trail and usually forces a context rebuild.
  • › Keep the expensive agent on the long path. Give the multi-hour task the durable session; give the quick tasks short sessions with tight briefs.
  • › Measure per branch. If one worktree is producing most of the spend with little output, the brief is the problem, not the model.

Because Quanta keeps Claude, GPT, Gemini, DeepSeek, Kimi, GLM, Qwen, Grok and the other model families behind one balance, this kind of per-worktree routing does not require per-team accounts or a budget spreadsheet per provider. The routing decision stays an engineering decision, and the spend stays a single number the team can act on.

05 · Merge order and the one worktree that stays authoritative

Parallel work ends in a serial bottleneck, and the teams that run these setups well treat the merge queue as a designed system rather than a habit. One worktree is designated authoritative: it holds the trunk branch, receives merges one at a time, and runs the full validation suite after each one. The other worktrees are read-only with respect to each other. They rebase or re-target their branches onto the updated trunk before the next merge, so conflicts surface in a small, attributable diff instead of in one enormous reconciliation.

  • › Merge in dependency order. Schema changes, shared interfaces and generated files go first; everything that consumes them goes after.
  • › Keep one human gate before trunk. Agent-written commits are excellent at being locally coherent and only average at being globally correct.
  • › Fail one branch at a time. A validation failure should block its own merge, not pause every other worktree.
  • › Keep reflogs intact. When an agent does rewrite something it should not have, recovery speed is what decides whether the parallel run was worth it.

Under this discipline, the head-to-head result is unambiguous. The shared checkout costs less to set up and far more to reconcile. Separate worktrees cost more in tokens and disk and produce branches that a reviewer can actually reason about.

06 · Rolling out six worktrees on one metered balance

The rollout itself should be boring. Create one worktree per slice, run the agents through the tools the team already uses, including Claude Code, Codex, Gemini CLI or anything speaking the OpenAI SDK, and point them at a single relay endpoint so spend and usage land in one place. Quanta is built for exactly this shape of load: a pay-as-you-go relay where one balance covers the model families a team needs, where every call is metered on real tokens with cache writes and cache reads priced separately, and where sustained parallel sessions are the normal case rather than an exception to explain to finance. Teams that bring other heavy users along also earn 19% of their top-ups, which is a reasonable way to fund the next rollout.

Start with two worktrees and one merge queue, measure the token spend per merged branch for a week, then scale to six once the prompt layout and the merge order are stable. Open an account on Quanta and run the first parallel session against your own backlog.