Skip to main content

Command Palette

Search for a command to run...

One Agent, One Worktree: Isolation and Concurrency for Coding Agents

Three coding agents start from the same checkout and finish in the filesystem they happen to inherit. Parallel coding is not primarily a coordination problem. It is first an isolation problem.

Updated
5 min readView as Markdown
One Agent, One Worktree: Isolation and Concurrency for Coding Agents
A
AI Architect. I design the boring control plane plumbing that keeps your impressive demos from quietly setting themselves on fire in production.

🗓️ Last updated: September 2026

Three coding agents start from the same checkout. One upgrades a package. One refactors the service that uses it. One fixes a test by changing the shared fixture. Each finishes successfully in the filesystem it happened to inherit. The combined branch resembles a group project in which nobody was told there were other group members.

Parallel coding is not primarily a coordination problem. It is first an isolation problem.

The unit of work needs a boundary

Give each agent a dedicated branch and working tree created from a known commit. Record that base commit with the task. The agent may inspect the wider repository, but it should modify only its own checkout. This creates a reviewable patch, prevents uncommitted changes from bleeding between tasks, and makes cleanup unsurprising.

Git worktrees are a practical local mechanism because they allow multiple working trees attached to one repository. Separate clones or ephemeral runners may be more appropriate for remote execution. The mechanism matters less than the invariant: one task owns one isolated filesystem and one branch.

Do not share build outputs between concurrent tasks unless the toolchain explicitly supports it. Generated files, package caches, local databases, ports, and containers can create hidden coupling. A clean source branch is not isolated if every agent points at the same mutable test database.

Concurrency starts with task topology

Before dispatching work, identify dependencies between tasks. Two independent documentation changes can proceed together. A schema migration and the code consuming that schema have an ordering decision. Two changes to the same central file may be logically independent and mechanically expensive to merge.

A useful dispatcher classifies tasks as independent, ordered, or conflicting. Independent tasks may run concurrently. Ordered tasks wait for a predecessor or branch from its result. Conflicting tasks should be combined or deliberately sequenced.

This is not multi agent choreography. The agents do not need to hold a committee meeting. The delivery system needs to understand the version graph.

Preserve the handoff artifact

Each task should finish with more than changed files. Require a compact handoff containing the base commit, commits produced, files changed, tests executed, test results, unresolved concerns, and any deviation from the contract. This artifact lets a reviewer understand the work without replaying an entire conversation.

Long running agent research from Anthropic similarly emphasizes incremental progress and structured artifacts that carry state across sessions. Git history already provides part of that structure. Use it. A transcript is useful for diagnosis, but a coherent commit remains the native unit of software review.

Merge through evidence

An agent branch should pass its scoped verification before entering the merge queue. The target branch must then run the required integration checks because other changes may have landed. Never assume that two green branches produce one green branch. Version control has spent decades offering educational examples to the contrary.

For conflicts, ask for a fresh analysis against the updated target. A textual merge that removes conflict markers may still violate behavior. Rerun tests and review the combined intent. High risk conflicts should return to a human owner.

Keep commits small and meaningful. An agent that mixes a functional change, formatting sweep, package upgrade, and generated file refresh into one commit has created a review hostage situation.

Control shared resources

Allocate unique database names, container names, ports, and temporary directories per task. Use scoped credentials and disposable environments for untrusted execution. Do not let two agents deploy to the same shared development slot unless testing race conditions is the actual assignment.

Limit concurrency according to the resources that are genuinely scarce: build capacity, external API quotas, integration environments, and reviewer attention. Starting fifty tasks is easy. Reviewing fifty simultaneous architectural decisions is merely a creative way to move the queue.

Failure modes

The first failure is branch isolation without environment isolation. Tests alter shared state and create results that cannot be reproduced.

The second is stale success. A branch passed tests against an old base and enters the target without current integration checks.

The third is invisible dependency. Two tasks were described as independent but change the same contract. A task topology review would have exposed the relationship before compute and reviewer time were spent.

The fourth is transcript dependence. Nobody can understand the patch without reading the agent's entire session. The code, commits, tests, and handoff should explain the result.

The architect's checklist

  1. Create one isolated branch and filesystem for every task.

  2. Record the exact base commit and execution environment.

  3. Classify task dependencies before parallel dispatch.

  4. Isolate mutable test resources and deployment targets.

  5. Require scoped tests before queueing and integration tests after merging.

  6. Preserve a structured handoff beside the commits.

Parallel agents can increase throughput. Without isolation, they mostly increase the speed at which unrelated assumptions meet in one branch.

Sources

  1. Git documentation for multiple worktrees

  2. Anthropic on harnesses for long running agents

Engineering With Coding Agents

Part 6 of 6

Four series of The Pragmatic Stack have explored the architecture and operation of LLM-powered systems: the discipline inside the agent, the systems around it, the operational practices that keep those systems running in production, and the .NET runtime used to implement them. All four series focused on systems that contain agents or agents that serve users. Series 5 examines a different kind of agent: one that opens your repository, understands your codebase, makes changes, and commits code. Coding agents are more than a new developer experience. They are a new actor in the software delivery system. Most delivery systems, including repositories, task backlogs, branching strategies, test suites, review processes, and deployment pipelines, were designed around human authors. Introducing automated authors changes the assumptions behind those systems. Some of those assumptions will need to evolve. Engineering With Coding Agents is a six article series focused on what needs to change and how engineering teams can adapt. This is the fifth series in The Pragmatic Stack. Series 1, Architecting Agents, covered the discipline inside an agent. Series 2, System Design, Reimagined, covered the systems around the agent. Series 3, Shipping AI Systems, covered how those systems are operated in production. Series 4, AI for the .NET Architect, covered what all of the above looks like in .NET. Series 5, Engineering With Coding Agents, covers what your software delivery system needs to handle agents as authors. What You Will Learn By the end of the series, you will have: A framework for making any repository legible to a coding agent without creating an extensive instruction manual. A task contract format that prevents vague intent from becoming production code faster than the team can identify and correct it. An isolation model for parallel coding agent work based on one branch, one worktree, and one environment per task. A six layer verification ladder that distinguishes software correctness from LLM benchmark performance. A code review approach designed for generated diffs at scale, with an emphasis on risk, provenance, and test evidence. A seven stage delivery loop that produces accepted, verified, and reviewable changes rather than raw generated output. The Articles 1. The Repository Is the Prompt: Preparing a Codebase for Coding Agents 2. The Ticket Is the Contract: Specifying Work for Coding Agents 3. One Agent, One Worktree: Isolation and Concurrency for Coding Agents 4. Tests Are the Verification Layer: Proving Agent Generated Changes 5. Reviewing Code Nobody Typed: Human Judgment in an Agentic Workflow 6. The Pull Request Is the Product: A Delivery System for Coding Agents Read the articles in order if you are building an agent ready delivery system from the ground up. If your organization has already begun adopting coding agents, start with the article that addresses the constraint you are currently encountering. The agent writes the code. The delivery system determines what reaches production.

Start from the beginning

The Repository Is the Prompt: Preparing a Codebase for Coding Agents

A coding agent did not fail to read the documentation. The repository stopped producing documentation years ago. Apparently, intelligence was expected to compensate for archaeology.