Ten agents, one codebase
Green tests on the wrong checkout taught me what coding agents need to own: their files, their test data, and a place in the queue.
An agent checked a change and got a green test run. The change was in a worktree, but the tests had used the main checkout.
The test paths pointed into the worktree. The command ran from the workspace root. My wrapper chose the main checkout, so the app imports came from there. The baseline and the proof both tested the wrong code.
That is the failure I worry about most now: a command that succeeds in the wrong place.
At work, I run up to a dozen coding agents on one product, on one laptop. The product I work on spans two main repos, a backend and a frontend. The hard part has been finding everything an agent can change that another agent assumes it owns.
A branch was only the start.
Follow the command, not the folder
I had already written wrappers to run commands in either repo. Originally, they found the repo from a fixed root. An agent could stand inside a worktree and still test the main checkout. Migrations could run against the wrong tree too.
A worktree gave the agent separate files. The wrapper quietly took that separation away.
Now the wrappers resolve the checkout from the current directory, including the matching sibling repo. If a pair is missing one half, they stop with an error. They do not substitute the main checkout.
The test command has a separate check. It refuses an absolute test path outside the checkout it resolved, then prints the command to retry in the right pair. That guard came from the false proof above. Fixing the resolver alone had not made every invocation safe.
I create a pair with wt <branch>: both repos, side by side, on the same branch. It gets a dev database copied from main and migrated to the branch head, a test template, ports, and dependencies.
Some of those boundaries are easy to miss. A shared Python virtualenv can import the main checkout because its editable install stores an absolute path. Different ports do not separate session cookies. Each pair therefore gets its own local hostname as well.
The database URL belongs in the pair's .envrc. The .env file is symlinked across pairs. Putting the URL there would quietly point every pair at main's database. The app preserves variables already set in the environment, so the per-tree export wins.
Then I put three implementers in one pair. The commit hook checked the whole working tree. One agent's half-written module blocked another agent's already-passed commit. Each retry cost a five-minute suite.
Separate tasks still shared a place to commit.
Now each committing agent gets a nest before it starts. wt <pair> nest <name> creates a nested worktree in each repo, with its own branch, dev database, and test template. Both halves matter: isolating only the backend leaves the frontend shared.
I give each agent its own place to commit, even when several agents work on the same feature.
Give each test run something it can destroy
Files were not the only shared state. Two agents ran the full suite against one test database. One run's concurrency-test teardown truncated every table while the other run still needed the rows.
The second run reported 2 failures and 5 errors. Alone, it was green. The failing tests changed between runs. We treated the failures as a regression and looked for a code bug.
A database per branch would still let two runs on that branch collide. The lifetime of the database has to match the lifetime of the run.
My test wrapper, bet, copies the tree's migrated template into a fresh database for each invocation. It runs pytest against that copy and drops it on exit. The cleanup trap is armed before the copy starts, so an interruption in that gap does not leave the database behind.
Templates belong to trees because branches can carry different migrations. If a template falls behind, or the migration contents change, the wrapper rebuilds it before the run.
An advisory lock still refuses a second runner on the same database. With separate copies, it is a backstop. If every run shared a database, the lock would turn away every run but one.
Isolation does not add cores
Even isolated work still had to fit on the laptop.
My first admission gate used the one-minute load average. With two orchestrators running and admitted jobs ramping up, load ranged from 45 to 98 on ten cores. A reading taken before a job gets busy cannot account for the work it is about to do.
The gate now counts leases as well as measured CPU idle. An admitted job reserves capacity. The hard caps are three suites and twelve agents; those are ceilings, not promises that every slot is available.
I budget 2.0 cores per suite and 0.5 per agent. The agent cost comes from a measured mean of 0.51 cores over 2,499 samples. Those are settings for my machine. The useful part to copy is the measurement and the reservation.
Disk needs a gate too. A nearly full disk stalled my local Postgres, and test runs hung for about half an hour without refusing to start. Now a suite refuses below 20 GB free on the database volume.
Waiting can also be a tool bug. After a merge inside a nest, a missing pass stamp made the commit check silently widen to the full suite. An agent waited more than 35 minutes on the critical path, with no message explaining why.
Today verify fast fails with a reason and a scoped retry when it cannot map a change to tests. Zero tests collected is a failure. A pass records a hash of the whole working tree, so the commit hook can recognise content already checked.
A green result needs to say what work it actually did.
Start with the next collision
I keep a papercut log so I can see which failures come back.
In an October review, 44 of 181 entries were recurrences. Fixes I had made as instructions came back; fixes I had made as tools stayed fixed in that review.
That changed my response to a repeat. Before I add another instruction, I ask whether a wrapper can reject the mistake. A missing checkout can be an error. A test run can own its database. A check can refuse to call zero tests a pass.
If you run several agents, trace one task from its edit to its test run to its commit. At each step, ask what it can overwrite, empty, or validate by accident. Give that state an owner whose lifetime matches the work.
Then try the command from the wrong directory. That is where my green proof fell apart.