blog /
Multi Agent Task Ownership for Parallel Coding Agents
Two agents fix the same bug at once, and the second one overwrites the first. Multi agent task ownership is the fix: exactly one writer owns each task, each owner works in a separate checkout, and every finished task merges through one review order.
- Carve the work into tasks that touch different files.
- Give each task one owner, one branch, and one worktree.
- Write the done definition and the handoff note before the agent starts.
- Merge in a fixed order, then retest the combination.
The coordination failure behind this workflow
Say you have two agents running in the same checkout. Agent A edits cart.py to fix a total. Agent B refactors cart.py at the same time. One of them commits, the other pulls or reapplies, and the fix silently disappears into a "merged" file that neither agent tested. The failure looks like a merge problem, but the real failure happened earlier: two writers owned the same files.
Shared checkouts also starve reviewers. When three agents push to one branch, the diff mixes three intentions, and no reviewer can accept or reject one task without touching the others. The result is the familiar stall: everyone waits for you to untangle the branch, which makes you the bottleneck the parallel setup was supposed to remove.
Ownership answers a narrower question than "who works on what." It answers "who is the single writer for these files until this task is done." Other agents may read those files. Only the owner changes them. Anything the owner needs from someone else arrives as a handoff note, not as a direct edit.
Set up multi agent task ownership and isolation
Split the work by file before you start any agent. Tasks that touch the same files run in sequence, never in parallel. Tasks that touch different files can run side by side. If two tasks must change one shared file, split the file first (one agent owns the top half behind a named function boundary, the other owns the rest), or sequence them and say so in the matrix.
The matrix below is the whole system on one page. Copy it into the task description, fill one row per task, and refuse to start an agent for a row with an empty cell.
| Task | Owner | Branch | Worktree | May change | Must not touch | Done when |
|---|---|---|---|---|---|---|
| Cart total fix | Agent A | fix/cart-total | ../shop-wt-cart | cart.py, test_cart.py | orders.py, schema files | Failing total test passes, full suite green |
| Order export | Agent B | feat/order-export | ../shop-wt-export | orders.py, test_orders.py | cart.py, schema files | Export test passes, full suite green |
| Schema migration | You, later | feat/schema-v9 | ../shop-wt-schema | schema.sql, migration notes | Everything the agents own | Both agent branches merged first |
Each row carries three isolation facts: one writer, one branch, one directory. A git worktree gives each owner a separate working directory on its own branch while sharing the same repository history. Create one per task:
git worktree add ../shop-wt-cart -b fix/cart-total
git worktree add ../shop-wt-export -b feat/order-export
git worktree list
Use the -b form for a new branch. The plain form (git worktree add <path> <branch>) needs the branch to exist already, and git fails on a missing name. Git also refuses to check out the same branch in two worktrees at once unless forced, which is the tool telling you that two owners claimed one task. When the task is done, git worktree remove takes the directory away; it refuses a worktree with uncommitted or untracked changes unless you pass --force, so a careless cleanup cannot silently drop work.
Some agents create the worktree for you. Claude Code accepts a --worktree flag that starts the session in an isolated worktree under .claude/worktrees/, and it blocks edits and commands aimed at the main checkout while the session stays there. Either path is fine. What matters is the invariant: one task, one writer, one checkout.
Give every agent the same written card before it starts:
Owner: Agent A
Task: fix the cart total rounding error
Branch: fix/cart-total
Worktree: ../shop-wt-cart
May change: cart.py, test_cart.py
Must not touch: orders.py, schema.sql
Done when: the rounding test passes and the full suite is green
Hand off with: branch name, failing-to-passing test names, anything left unverified
A card like this turns "the agent wandered into my files" from a mystery into a contract violation you can point at. For the review side of the contract, tell whether an agent is really finished before you accept any done claim.
Run the concrete parallel-agent scenario
Say you have a small shop repository with a green test suite. Two bugs arrive together: cart totals round wrong, and order exports drop the last row. The files do not overlap, so this is a genuine two-owner morning.
First, prove the baseline. Run the suite once in the main checkout before creating anything. If it is already red, fix that first or record the failing names; otherwise every later failure becomes an argument about whether the agent caused it.
Next, create the two worktrees and start one agent inside each, with the card pasted into its first prompt. Keep each prompt narrow: the file to fix, the failing behavior, the tests that decide. A prompt that says "fix the cart total and improve anything else you see" has just granted ownership of the whole repository, and the matrix cannot protect a task the prompt gave away.
While the agents work, stay out of their files. Your job during the run is to answer questions, not to edit. If you spot something in an owned file, send it as a message to the owner instead of opening the file yourself. Two writers means two writers, and you count as one.
When an agent claims it is done, check the claim from outside the agent. Rerun the suite in that worktree yourself, read the diff yourself, and confirm the branch holds only that task. Only then does the row move to review. The coordination rules for sharing one repository cover this separation of writing from verifying in more detail.
Handle collisions, reviews, and handoffs
Collisions come in three sizes, and each has its own response.
The small one is a branch collision: two agents end up pointed at the same branch. Git refuses the second checkout, which is your early warning. Stop, find the duplicated row in the matrix, and reassign one owner before restarting anything.
The middle one is a merge conflict: both branches changed nearby lines and git cannot combine them. Pick a fixed merge order in advance (cart fix first, export second, schema last) and merge in that order every time. The first branch merges into main, the second rebases onto the new main and resolves its own conflicts, then the same for the third. The order never changes midstream, so nobody has to ask you which branch goes first.
The large one is a semantic collision: the merge succeeds and the application fails. One branch renames a field the other branch calls. No merge tool catches this. The defense is the done definition plus a combination test run after all merges, on main, before any branch is deleted. A practical review sequence for parallel branches is described in the merge strategy for parallel agents.
Review is part of multi agent task ownership too: review each branch alone first. Since the agent already committed, compare with git diff main...HEAD (a plain git diff shows nothing after the commit) and read it as one task. Then merge everything and test the combination, because two correct branches can still disagree with each other.
Handoffs need the same discipline as merges. A handoff note names four things: what changed (branch and files), how it was verified (the test names that went from failing to passing), what is still unverified (anything the agent did not run), and who owns the next step by name. "Someone should check the export" is an unowned task and will sit until it rots. "Agent B owns the export retest on the merged main" will get done or visibly stall, and a visible stall is easy to reassign.
When you need supervision rather than more sessions
Three signs say the problem is no longer isolation. Agents keep blocking on decisions only you can make. Ownership questions recur faster than you can answer them. Finished tasks pile up waiting for review while new ones start. Adding a fourth agent to that scene adds a fourth queue, not speed. Multi agent task ownership still applies: every new task gets one owner, one branch, and one checkout, or it waits.
That is the point where a supervisor earns its place: something that reads each stopped agent's task record and plan, settles the reversible in-repo steps the way you would, and forwards only the decisions that truly need you. If you want the shape of that role, start with what coding-agent supervision actually is, then decide whether your setup needs one supervisor or simply fewer parallel tasks.
Doing this with qoop
Each ownership row maps to a checkout plus a visible terminal. qoop worktree new creates the separate checkout beside the repository, and qoop worktree ls shows every worktree with the terminals inside it, so a glance tells you which owner sits where. Removal refuses a tree that still has processes inside or uncommitted changes, which backs up the same rule this post states: cleanup never silently drops work.
The card each agent carries has a matching record on its terminal. Each terminal keeps the goal, the plan, the current stage, and the evidence behind each check, and qoop task verify confirms the ending from outside evidence (the pull request, the merge result, the install outcome) rather than taking the agent's word. That outside check is the same habit the scenario above practices by hand.
When an agent stops, qass reads that record plus the plan file and the repository rules, settles what its rules let it settle, and turns the remainder into cards on a board where one key answers. qoop delivers the notice: the row lights up, and qoop sends a desktop notification naming the agent when you are not already looking, so answering three owners feels like clearing a short queue instead of watching three terminals.
If parallel tasks keep colliding in your repository, sign up at qoop and run the next two-owner morning with the matrix above.