Chapter 17 of 18

Many agents

Parallel work, roles, handoffs, loops, evals and factories: running a team that never sleeps and never remembers.

One agent is often enough. This chapter is about the times it is not, and how to tell. Running many agents multiplies what comes out, and that includes the mistakes, the conflicts, the code nobody asked for, and the bill. Everything here is a way of getting more of the first without drowning in the rest.

Each new agent starts with no memory of the others. They do not overhear each other, and they do not remember yesterday, so anything they need to share has to go in a file, a branch or a test. That single fact explains most of what follows: worktrees, roles, handoffs, progress files, loops.

A lot of what gets written about this is reported by the people selling or running it, and few numbers have been measured from outside. We say which is which as we go. When a claim comes from someone quoting someone, we say that too.

The argument runs in order. How to split work, and what splitting costs. How to split jobs, so that the one who writes is not the one who judges. How to split time, across sessions that cannot remember each other. Two whole systems and the factory idea built from such parts. What builds up when nobody is looking. And the last term, which matters as much as the rest put together: when not to.

First, splitting the work. It looks like simple arithmetic: three agents, three times the speed. Here is what the arithmetic leaves out.

Parallel agents

Several agents work at the same time on separate parts of a job, each in its own session. You get more done per hour only if the parts really are independent, and only if you can check all of what comes back.

The limit is rarely the agents. It is how cleanly the work splits and how much you can review. Starting a fourth agent takes seconds, and reading what it did does not.

Say it to your agent

“Split this into tasks that touch different files. List the files for each task, and tell me which ones can't be separated. Don't start any of them until I've picked.”

Fan-out

Also called fan-in, map-reduce with agents

One job is split into pieces, each goes to its own worker at the same moment, and their results are gathered into one answer, which is the fan-in. The whole job takes as long as the slowest worker, plus the gathering.

It suits reading far better than writing. Ten agents can look through ten modules and report back without touching each other. Ten agents editing the same app cannot.

Say it to your agent

“Use subagents to read each package under src/ and report every place it calls the old auth client, with file and line. One subagent per package. If one fails to report, tell me which, and don't treat it as "nothing found".”

Orchestrator

Also called coordinator, orchestrator-workers

An agent whose job is running other agents. It splits the work, briefs each worker, tracks what comes back and judges it, and writes no code itself. A mistake in its brief is repeated by every worker it sends.

You can't watch fifty agents, and neither can your context window. An orchestrator holds the plan and stays small, because the details stay in the workers.

Say it to your agent

“You're coordinating, so don't edit code. Run one unit first and show me the result before you start the rest. For each worker, read its diff yourself. Don't pass on its summary as fact.”

Worktree isolation

Each agent gets its own git worktree: a separate folder with its own branch, sharing the same repository. One agent's half-saved file can't break another's test run, and an edit can't quietly overwrite another. They only meet at merge time.

Agents on one folder do not see each other coming. One saves a file the other read a minute ago, and the first agent's work is gone with no error. Two worktrees turn that silent loss into a merge conflict you can see.

Say it to your agent

“Do this in its own git worktree on a new branch, not in this folder. Run the tests there. Use a separate test database and port, and tell me which you chose.”

Now the bill for splitting. This is the term the launch posts tend to skip.

Coordination cost

The time a team spends staying in step and not working: waiting, conflicts, re-reviews, explaining things again. It grows with the pairs of workers and not the workers. Past some point, adding one makes the whole team slower.

Agents make this worse in one way. They are confident, they do not talk to each other unless you build that, and each conflict costs another run and another review. A reviewer is a queue too, and that queue is you.

Say it to your agent

“Before you add another agent, show me how much time the current ones spent waiting or redoing work. If that's rising, we fix the split or the review first.”

Merge queue

Pull requests wait in line, and each is tested on top of main plus everything ahead of it before it merges. Two changes that pass alone and break together get caught before they reach main, not after.

Agents open pull requests faster than people do, so two green ones colliding stops being rare. One renames a function, the other adds a new call to it. Git sees no conflict, and main is red for everyone.

Say it to your agent

“Add merge_group to the triggers of our required CI workflow, alongside pull_request. Then tell me the exact setting I need to turn on in branch protection, since you can't do that part.”

Next, splitting the jobs. Here the point is less speed than making sure the one who writes is not also the one who decides it is good.

Roles

Also called role specialisation, specialised agents

Give each agent one job with its own prompt, tools and check: one writes specs, one writes code, one tidies, one reviews. Each is told what not to do, so that each check stays with someone who did not write the code.

An agent asked to do everything cuts its own corners, and marks its own work. Roles put the corner and the check in different hands. Every role is also another handoff, another prompt to maintain and another bill.

Say it to your agent

“You're the reviewer on this, so don't edit anything. Run the code and report what fails, with output. Someone else will fix it. If everything passes, say so and stop.”

Evaluator-optimiser

One side writes and the other judges, in a loop. The judge's notes go back to the writer until it passes or the tries run out. It works when the judge has clear criteria, and the result ends up as good as what the judge can see.

Agents grade their own work too kindly. Splitting the writer from the judge fixes more than a stricter prompt does, and an automatic loop saves you from carrying the notes yourself. A blind spot in the judge stays a blind spot, however many rounds you run.

Say it to your agent

“Write this, run ./check.sh, and read what it says. Fix what it reports, and run it again. Stop after four tries, or when it passes, and show me the full output of the last run either way.”

Adversarial review

A reviewer whose job is to break the work and not to approve it. It is fair only when each finding must be proved by a run. Without that rule, a reviewer told to find problems will find problems, whether or not they exist.

A pushy prompt finds more real bugs and invents more false ones, and every round costs tokens you could spend on a test or a real run. Asking for a failing run first makes a false alarm cheap to spot, because an opinion cannot produce one. It doesn't make the round free, and the author of the best-known rule for this now doubts it pays.

Say it to your agent

“This change retries payments, so I want one targeted attempt to break it. Name the property you are attacking, write a script that fails, and paste the output. Leave out anything you did not run, including style. No findings is a fine answer. Don't fix anything. If a property test or a real run would answer this for less, do that and tell me.”

Third, splitting the time. Sessions run out, and memory does not carry over, so the work has to survive in files.

Ralph loop

Also called Ralph Wiggum loop, Ralph

The same prompt, fed to a fresh agent, over and over, in a shell loop. Each run does one thing, writes down what it did, and exits. Its memory is on disk. It is cheap to set up, and it has no way of stopping unless you build one.

A fresh session each time means no drift and no bloat, and a loop means it carries on while you are away. It only works with a plan on disk, a check that can say no, and a limit, or it will happily spend your money making things worse.

Say it to your agent

“Write me a script that runs claude -p in a loop on PROMPT.md: one item from fix_plan.md per run, then commit. Stop when ./check.sh passes or after 20 runs. Pass --max-turns and --max-budget-usd each time.”

Long-running agents

An agent working on one goal for hours or days, usually across many sessions that cannot remember each other. What lets it last is outside the model: a plan on disk, notes on progress, tests it can run, and a clean way to start again.

Nothing goes well for long on its own. Each session starts cold, and long ones drift or declare victory early. A run this long is decided by the harness you set up before it began.

Say it to your agent

“This will take more than one session. Before you code anything, write the plan to PLAN.md and a feature list with a test for each. In each session, read those first and work on one item only.”

Progress files

A file in the repo saying what has been done and what comes next, which each new session reads first and updates last. It is how a session with no memory finds its place. It is only as true as whatever checks it.

A fresh agent believes the file, so a wrong line sends every later session the wrong way. Agents also like finishing, so "done" gets written too soon. Tie each claim to a test that a script can run.

Say it to your agent

“Keep features.json with an id, a step and passes for each feature. Only change passes, and only after its test really passes. Never remove or reword a feature. Read it at the start of each session.”

Handoff artefacts

A file one agent commits for the next to pick up: a spec, a diff, a report. Unlike a chat message it outlives the session, has a version, and can be checked. If you pass a commit, the next stage knows exactly what it received.

A summary passed along a chain changes at each step, like a game of telephone. A committed file doesn't. It also means you can open what each stage really handed over, not what it said it did.

Say it to your agent

“Write your findings to reports/auth-audit.md and commit it, with the commit hash in your final message. The next agent gets that file, and it won't see this conversation.”

Checkpoints

A saved state you can go back to when a run goes wrong. Claude Code makes one per prompt, covering files its editing tools changed. Git commits cover everything git tracks. Neither can undo a database change or a sent email.

An unattended run makes many changes before you look, so you need to know how far back you can go, and what that leaves behind. People find out that files changed by shell commands are not covered at the worst moment.

Say it to your agent

“Commit before each step of this, with a message saying which step. Don't run migrations or anything that touches a database or external service without asking me, since git can't undo those.”

Scheduled agents

Also called routines, cron agents

An agent started by a clock or an event and not by a person: triage overnight, check a deploy every five minutes. Nobody is watching when it runs, so it needs narrower permissions than you'd give yourself, and its own way to stop.

It is the cheapest way to get work done while you sleep, and also a good way to get surprised. It acts with whatever access you gave it, on a schedule you may have forgotten about.

Say it to your agent

“Every morning, read the open issues labelled bug, try to reproduce the newest, and post what you found as a comment. Don't push code or close anything. If you find nothing new, say so and stop.”

Runaway loops

Also called cost runaway

A loop that keeps spending because nothing told it to stop, or a growing session where each turn resends everything before it. Spend rises with every turn, and if nobody is watching, the first sign is the bill.

A bug in ordinary code wastes CPU. A bug in a loop wastes money and carries on doing it, since a confused agent often does more work, not less. Set the cap before you leave. A cap you add afterwards helps nobody.

Say it to your agent

“Run this headless with --max-turns 30 and --max-budget-usd 5. If either limit stops it, write what is left to do into PROGRESS.md so I can decide whether to carry on.”

Now, two whole systems, built on opposite ideas. They are worth comparing because each one answers the same questions differently.

SwarmForge

A tool for running a line of AI agents, one role each, in separate git worktrees and tmux sessions (tmux keeps several terminals running side by side). Work passes on as committed handoffs, and you approve it at a gate.

It is the clearest public example we found of using checks in place of reading the code: every role owns one gate, so trust comes from the line and not from anyone's eyes. Whether that is enough is exactly what people disagree about.

Say it to your agent

“Clone unclebob/swarm-forge, check out the two-pack branch, and read the role prompts and README with me before running it. Explain what each role can and can't do, and what approval I would be giving.”

pstack

A set of skills by Lauren Tan (poteto) for Cursor and Claude Code. It teaches going deep with one agent first, then running many with proof. It is instructions for the agent you already use, with no runtime of its own, and poteto-mode is the router.

It shows that a lot of this can live in text. Its central claim is an order of work: earn trust in one agent's output, and only then parallelise. It also has the most exact public rules we found for what counts as proof before a merge.

Say it to your agent

“Install pstack with /plugin marketplace add cursor/plugins, then /plugin install pstack@cursor-plugins. Read me the shipping playbook, then tell me what we would need to change to follow it here.”

Software factory

A setup where specs and scenarios go in, and agents write, test and ship code, with few or no people reading it. People build the line and its checks. The phrase names a way of working. It is not a product, and not a measured result.

If it holds, your job moves from writing code to writing checks that decide whether code is any good. If the checks are weak, you get a lot of confident software that nobody understands. Everything turns on that if.

Say it to your agent

“Look at what we would need before agents could ship this service unread: which behaviours have no scenario, which checks a change could fake, what we couldn't roll back. List gaps only, and don't change anything.”

Dark factory

A software factory where no person writes or reads the code, so the lights can stay off. All the trust has to come from evidence such as hidden scenarios and real runs. Few teams claim to do this, and we found no outside audit of any.

It is the far end of the range, and it is useful to think about even if you never go there, because it forces the question: if you stopped reading this code tomorrow, what would tell you it broke? For most teams, the honest answer is the customers.

Say it to your agent

“Suppose nobody reads the code in this repo from tomorrow. List each way it could break in production without any of our checks noticing, most likely first. Don't fix them yet.”

What builds up when nobody is looking.

Entropy

Agents copy what they find. Good and bad patterns alike spread with every run, so a repo nobody tidies gets less consistent, and faster than people alone would make it. No single change looks wrong. The drift shows up later.

More agents means more copying per day. The harm is that bad patterns become examples: the next agent finds them, sees that they pass, and copies them. A rule enforced by a machine is the only kind that works at that speed.

Say it to your agent

“Find every place we call fetch directly instead of apiClient. Add a lint rule that fails on it, naming apiClient in the error message. Fix the five oldest in this pull request, and list the rest.”

Garbage collection agents

Also called doc gardening, doc-gardening agent, cleanup agents

Small background agents that each look for one kind of decay, such as stale docs or a broken convention, and open tiny pull requests to fix it. They pay down entropy in small amounts, so nobody has to hold a clean-up day.

Small fixes are cheap to review and easy to automate. A giant clean-up is expensive and gets put off. Stale docs matter more with agents, because an agent believes them.

Say it to your agent

“Every Monday, compare docs/ with the code. For each statement that is no longer true, open one small pull request fixing only that. Don't reword anything that is still correct, and don't merge.”

Finally, how you would know any of this helped.

Eval-driven development

Write down what good looks like as a set of scored cases before you change anything, then change the prompt or harness and run them again. An eval is a test of behaviour across many runs. It tells you if the change helped, not how it felt.

With agents, a change can feel better and be worse, and any single run can mislead you. If you don't set the bar first, you will end up picking the bar that suits the result you got.

Say it to your agent

“Before we change this prompt, build an eval: 20 past failures and 20 good cases. Decide and write down what score counts as better. Run it 3 times on the current prompt, then on the new one, and show me both.”

When not to

Most work does not need many agents. If it fits in one session, or the parts share files, or you can't check the output, use one. If you could do it in the time it takes to write the brief, use none. Add more only once you have measured a gain.

Every idea in this chapter adds something to run, pay for and understand. Many agents can feel productive because a lot is happening. The test is whether more correct work reached users, per hour of your attention. Very often it did not.

Say it to your agent

“Before you plan anything: would one agent in one session be enough for this? Say yes unless you can name the parts that are truly independent, the files each one touches, and how I would check each result.”

Do it for real

Reading gets you the words. This gets you the experience behind them, and something to show.

Lose work on purpose, then stop losing it

It is easier to believe in worktrees after you have watched a silent overwrite happen, and then watched git refuse the same thing.

  1. In a scratch repo, start two agents in the same folder. Ask each to change a different function in the same file, and have the second read the file before the first saves.
  2. Look at what is left. Note which change vanished, and whether anything told you.
  3. Start again with git worktree add for each, or claude --worktree, and give them the same two tasks. Merge them.
  4. Now give both agents the same line, and merge. Resolve the conflict by hand.

Done when: You have notes on what was lost in the shared folder, a clean merge from the worktrees, and one conflict that you resolved yourself.

Build a Ralph loop that can stop

The difference between a useful loop and an expensive one is three short lines of script. You should write those lines once, by hand, and see each one fire.

  1. Pick a small greenfield task with tests that can fail: a slug function is enough. Write PROMPT.md, fix_plan.md and an empty progress.txt.
  2. Write a shell script that runs claude -p once per loop, with --max-turns and --max-budget-usd, and exits when your check script passes, or after a set number of loops.
  3. Run it and watch the first few loops, as Huntley advises. When it fails in a new way, change the prompt or the check and not the code.
  4. Set the budget far too low, and confirm it stops. Then remove the plan's last item and confirm the loop exits rather than inventing work.

Done when: You have the script, a log of it stopping because of the check, and a log of it stopping because of each limit.

Measure one agent against three

Almost everything said on this subject is opinion. You can have your own evidence, for your own repo, in an afternoon. Sometimes you will find that three lost.

  1. Choose two real tasks: one that splits into separate files, and one on a shared schema or file.
  2. Decide first what you will count: wall-clock time, your own minutes, tokens or dollars, conflicts, and defects you found afterwards.
  3. Do each task with one agent, then again from the same commit with three in worktrees. Write down the numbers as you go.
  4. Write three sentences: when three won, when it lost, and what you will do next time. Keep it in the repo.

Done when: You have a small table of four runs against the measures you set in advance, and a rule of your own based on it.

The build, stage 17 of 18

Two agents, one repo

Two agents in two worktrees, a merge conflict you settled by hand, a loop that stopped on its own budget, and a note on when one agent was better.

About 90 to 150 minutes, on the same app as every other stage. We ran it first and show what went wrong.

Open stage 17 of the build

Gate 17: Many agents

0 of 6 right

  1. 1Three agents are adding features. All three must register a route in the same routes.ts. They are in separate worktrees. Merging is slow and full of conflicts. What do you change first?

  2. 2Two pull requests are both green, and git reports no conflict. After merging both, main fails: one renamed a function and the other added a call to the old name. What would have caught this?

  3. 3You have written while :; do cat PROMPT.md | claude -p ; done and are about to go home. What is missing that matters most?

  4. 4A colleague says: "Uncle Bob built a product called the Gauntlet, and he has proved you never need to read agent code." How much of that holds up?

  5. 5A verifier passed PR 2 of a four-PR stack. Then main moved and the whole stack was rebased, so every SHA changed and CI is green again. What should happen to that verdict?

  6. 6You need to change one error message, in one file. The team's harness can start eight agents, with a reviewer and a merge queue. What do you do?

Get every answer right to install it, and to put 2 files in your repo. Wrong answers cost nothing.

Next chapterThe proof

The workshop

Name a word, or describe what you mean in everyday language.