The fleet regime
When one agent is enough, when you need several, and when parallelising costs you more than it returns
- Module
- Module 01
- Deliverable
- regime-de-flotte.md (three tasks put through the grid, with a verdict and a justification for each)
- Access
- open, in full
Before you read
- What you will be able to do
By the end, you decide the number of agents before you launch, by writing your verdict on three criteria, and you can justify the choice to someone who disputes it.
- What you will do
- Action 1: Cross-check the files of two subtasks
- Action 2: Look for the files nobody owns
- Action 3: Write the command that judges a subtask
- Action 4: Recount a fact from your last instructions
Then the exercise: Trois tâches de votre liste de tâches passées à la grille, avant de rien lancer (in French)
- Time
38 min reading, 45 min exercise
- Updated on
- Before you start
Nothing in particular: the module stands on its own.
- Words used in this module
- toolThe software that runs your coding agents, and that has them read, at launch, the project's instructions files.
- sessionA conversation with the tool, which keeps its own history; a subagent works in its own, and a fresh session starts without the history of the others.
- instructionsThe text an agent receives at launch, from you, from the session that launches it or from the instructions files the tool has it read: what it must achieve, what it must not touch, facts about the code.
- agentA session you open, or a subagent that a session launches; it writes, meaning it modifies files, unless its instructions forbid it: it is then read-only.
- fleetAll the agents working for you at the same moment, sessions and subagents together.
- taskThe work you want done, a ticket for example, which goes whole to one agent or is split into subtasks.
- subtaskA piece of work given to a single agent: a part of a split task, or a whole task.
- waveWriting agents launched together, three at most to start with (a starting point that your measurements can raise); the next agents only start once their results are merged.
- batchAll the work you plan to give to agents together, in one or several waves: a task you split, or several tasks.
- regimeThe way of organising a fleet on the work you give it: how many agents, which ones may write, and in what order.
- salvoFive to eight agents launched at the same time, all read-only, to cover a lot of ground: audit, exploration, research.
- adversarial reviewA review where each agent looks for what is wrong in a result, from an imposed angle, without seeing what the others find.
- worktreeA second working copy of the same git repository, on its own branch, with its own files but without its own local database or its own ports.
- quotaThe amount your subscription gives you to consume over a given period, all open sessions together.
- silent mergeA merge that git accepts without reporting a conflict, and whose result is wrong.
- handoverThe document a session leaves to the next one so that it can take up the work.
The reflex that costs you
Take a Friday, 17:00. Three tasks on your task list, three agents launched, because it is possible. On Monday morning, it takes half a day to untangle the result. Two branches modified the same configuration file. Git merged them without reporting a conflict, and the resulting file matches neither of the two intentions. The time saved on Friday is lost again on Monday.
Nobody decided the number of agents: it was deduced from the number of tasks. Yet three tasks say nothing about their independence, or about how to verify their result. They say nothing about integration either: the work of merging their branches, then verifying the merged result. Those are the questions that decide.
Decide the number of agents before you launch, in writing, criterion by criterion.
A written decision can be defended in front of someone who disputes it. A number you raise when all goes well and lower when things break cannot be defended: nobody wrote down why.
An agent, here, is a session, a conversation with the tool that keeps its own history, that you open; or a subagent that a session launches, in a session of its own. At launch it receives instructions: the text that tells it what to do, coming from you, from the session that launches it or from the instructions files its tool has it read. It is read-only if its instructions forbid it to modify files; otherwise, it writes. If the tool, the software that runs your agents, can block writing, turn that block on too. This block matters, because an agent can ignore its instructions, but not a refusal from the tool. This module calls fleet all the agents working for you at the same moment, sessions and subagents together. It calls regime the way of organising them on the work you give them: how many agents, which ones may write, and in what order. A task, a ticket for example, goes whole to one agent or is split. A subtask is the piece given to a single agent: a part of a split task, or a whole task.
When this module is useless
Do you work alone, on one repository, one task at a time, and your tasks do not split into
independent pieces? The criteria of this module will answer "one writing agent" every time, and
your single agent already does the work. Read only two passages, which also hold for a single
agent: the Duo row of the regimes table (a second agent reviews before the merge into main), and
the section "The instructions that lie". For the rest, save your time, and come back the day you
launch three agents on a Friday evening.
The six regimes observed
This module distinguishes six regimes, drawn from the projects that were used to write this manual. The table says, for each one, its shape, where it wins and where it loses.
| Regime | Its shape | Where it wins | Where it loses |
|---|---|---|---|
| Solo | One agent, one session, one task | Most tasks: it is the default regime. When the result goes into main, add a reviewer to it, which makes it a duo (next row) | When the task really splits, and you wait needlessly |
| Creator and reviewer duo | One agent produces; a second, read-only, reviews the result in a fresh session, without the first one's history | Anything that will be merged into a shared branch, such as main | On throwaway code: you verify what you are going to throw away |
| Design, build, review trio | Three roles, each in its own session: one prepares the plan of the task, another writes the code, the last one reviews | A task that needs a plan, and whose decisions you want to keep a trace of | When several subtasks could move forward at the same time: only one of its roles writes the code, so they go one after the other |
| Exploration salvo (5 to 8 agents) | Several agents launched together, all read-only: audit, exploration, research | Covering a lot of ground, fast, without breaking anything | As soon as one of its agents writes: it is no longer a salvo, and that agent follows the rules for writing agents, further down |
| Adversarial review | Several agents look for what is wrong in a result, each from an imposed angle (security, edge cases, performance…), without seeing the others' findings | Finding what a green test suite hides | When the angles overlap: five reviewers find the same thing five times |
| Sequential pipeline | The task split into subtasks that follow each other, each in a fresh session | Long tasks, where a session loses the thread before the end because its history gets too long | Time: nothing runs in parallel |
Remember two things above all. First a possibility: when you run a series of tasks, the three roles of the trio can run at the same time, each on a different task. One agent designs the next task while another writes the code of the current task and a third reviews the previous one. Only the agent that writes the code modifies the repository. The designer and the reviewer return a report in their response, without creating or modifying a file: they are read-only. These reports, which you keep, are the trace of the decisions.
Then a rule: two subtasks that modify the same files, write to the same local database or use the same ports never run at the same time. One agent does them one after the other.
A worktree, meaning a second working copy of the same repository on its own branch
(git worktree add), gives each agent its own copy of the files: the agents do not overwrite each
other during the work. Two copies of the same file, modified by two agents, still meet at the
merge: git reports a conflict, or merges without reporting anything, and the result can be wrong.
And the worktree does not separate what lives outside the files: a local database or a port that
both copies use.
In my own practice, the worktree stays the exception. I am the author of this manual, and "I" always refers to my own practice.
The tool's cap and the subscription's quota
Your tool may cap the number of agents running at the same time: mine does. Your subscription caps what all your sessions consume together: that is the quota. The cap refuses one more agent. The quota lets everything launch, then cuts everyone off at the same time.
Since the quota cuts everyone off at once, deciding the number of agents also means deciding how many tasks can stop halfway at the same time. In the instructions of each agent that modifies files, ask it to commit as soon as a piece of work stands up: a finished file, a test that goes green again. Instructions that do not say so bet that the quota will hold.
The three decision criteria
Let us call batch all the work you plan to give to agents together, in one or several waves: a task you split, or several tasks. The criteria apply to its subtasks: each piece of work given to a single agent. It can be a part of a task you split, or a whole task you would like to launch at the same time as others. The writing subtasks of a batch go out in waves: writing agents launched together, three at most to start with (see further down).
Three criteria, in this order, make up this module's grid, also published on its own under the name parallelisation grid (see the last section). Criterion 1 is asked for each pair of subtasks, criterion 2 for each subtask, criterion 3 for the whole batch. The subtasks hit by a "no" at criterion 1 or criterion 2 run in series: one agent does them one after the other. At criterion 1, that is one agent for each set of subtasks that overlap. This holds step by step: if A shares files, a database or ports with B, and B with C, all three go to the same agent. At criterion 2, that is a single agent for all the subtasks that answer "no" to it. The subtasks brought together this way at criterion 1 form a group, given to a single agent, and never again run at the same time as each other. The group then answers criterion 2 as a single subtask. If a command judges the group's result, meaning it fails when the result is wrong, the group's agent runs at the same time as the other agents of the wave. Otherwise, the group joins the subtasks you review yourself: criterion 2, further down, gives them all to a single agent, which does them one after the other. A group's agent counts among the writing agents of its wave, and the next wave waits until it has finished. The other subtasks continue through the grid. Criterion 3, for its part, is asked for the whole batch: if it answers "no", the whole batch goes back to a single agent.
Criteria 1 and 2 concern only the subtasks given to writing agents. One exception: a read-only agent that runs tests or a server uses a database or ports, and criterion 1 applies to it for those resources. Read-only agents modify no file, but you reread their reports: count that rereading time in criterion 3. Criterion 3 says whether these read-only agents are worth their cost, and so whether you launch them. Launch eight at most at a time, all sessions together: that is the maximum of the salvo. The grid in the last section in fact starts with the question "Will the agents modify files?".
Criterion 1: do the subtasks modify different files, sharing nothing?
This is the criterion people think they checked without checking it. Two unrelated tickets can modify the same routes file, the same database schema or the same translations file. Check on file paths, never on ticket titles. Two subtasks that answer "yes" to this criterion (no file, no local database, no port in common) are called disjoint.
| Situation | Verdict |
|---|---|
| Each subtask modifies different files, with no local database or port in common | Yes: go on to criterion 2 |
Two subtasks modify the same file, including the dependency lockfile (package-lock.json, pnpm-lock.yaml…), a schema or a configuration | No for those two: one agent does them one after the other, unless you split again so that only one touches it. Launched in parallel, they risk a merge that git accepts without a conflict and whose result is wrong |
| Two subtasks write to the same local database (migrations, test data) or start a server on the same ports | No for those two: their files differ, but they get in each other's way while running |
| You do not know | Check before launching, with the command below |
The danger is called a silent merge: git accepts the merge without reporting a conflict, and the result is wrong. Within one file, git reports nothing when the two branches modified lines far from each other, even if the two changes do not go together. So the absence of a conflict does not prove that the result is right.
Different files do not protect against everything. If one subtask changes the signature of a function that another calls from another file, the merge goes through and the code breaks. Criterion 2, further down, catches part of this: the commands that judge the results are also rerun on the merged result.
Action 1: Cross-check the files of two subtasks
Before launching anything that writes, open one session per subtask, read-only. Ask it for the
list of files it expects to have to modify, one path per line, relative to the root of the
repository and without ./ at the start: comm compares exact strings. Save each list in a file,
then compare them two by two (these commands need bash or zsh). The command displays the paths
present in both lists:
comm -12 <(sort sous-tache-1.files) <(sort sous-tache-2.files)
The command sees only files: a shared local database or shared ports also force you to do the subtasks one after the other. Afterwards, on branches already produced, the same check becomes:
comm -12 <(git diff --name-only --no-renames main...branche-1 | sort) \
<(git diff --name-only --no-renames main...branche-2 | sort)
The three dots matter: main...branche compares from the point where the branch left main. Two
dots would compare with the current state of main, which may have moved in the meantime. The
--no-renames option lists a renamed file under both its paths, the old one and the new one:
without it, a branch that renames a file while another modifies it would pass the check. The lists
of the first command are an agent's forecasts: rerun the comparison on the branches, with the
second command, before merging.
Expected result: Empty list: parallelisable as far as files go. Otherwise: one after the other, or split again.
Criterion 1, the other side: the split that leaves gaps
Criterion 1 checks that two subtasks do not overlap. It does not check that the subtasks, together, cover the whole task. That gap produces no conflict: it produces work nobody did. Some tasks must go over a whole set of files: a renaming, or a harmonisation, meaning the same change of appearance applied everywhere. For those, give each subtask a scope: the folders or files it is in charge of. We say it owns them: it alone writes there. Then check the split with two comparisons: the intersection of the scopes, as in criterion 1, and the remainder, meaning the files no scope contains.
Action 2: Look for the files nobody owns
List the files the task must cover, then those in the scope of each subtask (perimetre-1.files,
perimetre-2.files…). These lists contain files, not folders: git ls-files on each folder gives
them. Then remove the files of the scopes from the full list. The example takes all of src/, for
a change that touches the whole application:
# what the task must cover, in full
git ls-files src/ | sort > tout.files
# what the scopes cover, together
cat perimetre-*.files | sort -u > couvert.files
# what nobody owns
comm -23 tout.files couvert.files
Expected result: Empty output: the split covers everything. Otherwise, the list of files nobody owns, to assign or to set aside for after integration.
At the end, count what is left to do on the whole task, with a command run on the whole set. Never add up the agents' reports: only you, who did the split, see what falls between two subtasks.
Criterion 2: can a command judge the result?
Ask whether a command settles it, not whether you will be able to judge. In this criterion, "review" means that you review it yourself: review by an agent, as in the duo, does not replace the command. Read-only agents fall outside this criterion, because they produce no code to merge; the time to reread their reports goes into criterion 3. If you have to review each result to settle it, parallelising only fills your review queue: the bottleneck is you.
| Situation | Verdict |
|---|---|
| A test or a script fails when the result is wrong | Yes: go on to criterion 3 |
| Only a human can judge whether the code does what was asked | No: a single agent for these subtasks, one after the other, and you review each result yourself |
| The result is an architecture or product decision | No, and do not delegate: make the decision yourself. An agent can prepare it (the options, their consequences), not make it: you are the one who bears the consequences, and no command says whether it is good |
A green type check or lint is not enough: it says the code is well formed, not that it does what was asked. You need a command that fails if the result is wrong.
Architecture decisions aside, the subtasks that answer "no" to this criterion go to a single agent. It does them one after the other: you review each result before the next one, even if their files differ. At criterion 1, it was something shared that grouped subtasks; here, it is your review: you review only one result at a time. As at criterion 1, this agent is part of a wave, counts among its writing agents, and the next wave waits until it has finished.
On the merged result, rerun all the commands that judge the subtasks of the batch, plus the type check and the lint, and not only each one on its branch. Together, they can catch two subtasks that modify different files but break together: the type check spots a changed function signature. None of them guarantees it: a command judges only what it tests.
Action 3: Write the command that judges a subtask
Take the next subtask you intend to give to an agent, a whole task or a part of a task. Write the
command that will fail if the result is wrong: a test, a script. If you cannot write it, note
"none". That is the answer to criterion 2. For a new feature, run the command before the agent's
work: it must fail, otherwise it judges nothing. For a rewrite that must change nothing in the
behaviour, you need two. The first passes before and after: nothing broke. The second fails until
the rewrite is done, for example grep -rq 'old_name' src/; test $? -eq 1. It passes only if
grep was able to search and found nothing.
Expected result: A written command: for a new feature, it fails before the agent's work; for a rewrite, two commands, one that passes before and after, the other that fails until the rewrite is done. Or the word 'none': then a single agent that you review; for an architecture decision, you decide yourself.
Criterion 3: does the gain cover the cost?
The third criterion comes after the other two, and it is the one people forget. It never makes up for a "no" at one of them. A subtask that fails criterion 1 or criterion 2 stays with a single agent, whatever the cost.
The question: is the time you gain by launching several agents worth what they cost on top? The measurement will come from module 5. You can already answer with an estimate, in three steps.
- The gain. Count the waiting time avoided: the duration of the batch done in series, minus its duration in parallel. In parallel, the subtasks go out in waves, with, to start with, three writing agents at most per wave. Each wave lasts as long as its longest agent: an agent that does several subtasks in a row counts for their sum. The waves add up. Take away from this gain the time that parallel work adds: merging the branches, rerunning the command of criterion 2 on the merged result, rereading several reports in a row.
- The cost. If you pay by usage, estimate the extra spend with the table further down. It counts per day of use; for a batch of a few hours, take a share of it in proportion to a working day, roughly. Compare for example one agent and three: the gap is approximate, as the note under the table says. On a subscription, the price does not move: the cost is the extra share of quota. Two signs tell you: the consumption your tool displays, if it displays it, and past cut-offs. If your usual fleet has never used up the quota, you may have some margin; the displayed consumption tells you how much.
- The verdict. Paid by usage: yes if the gain, at the price you put on one hour less of waiting, exceeds the spend. On a subscription: yes if the gain stays positive and the quota has margin. No if you cannot put a number on the gain. No too if your quota has already been used up, in recent weeks, with your usual fleet: one more agent will empty it sooner. That was my case, with eleven windows used up over the period recorded further up. The cut-off will then stop everyone (see "The tool's cap and the subscription's quota").
It is an estimate, not a measurement. Module 5 replaces it with your own reading.
A public figure also shows the gap that the choice of model makes. Five agents cost about $81 a day when all of them run on the most expensive model, and $39 when only one keeps it. In the second case, three agents run on the middle model and one on the lightest. This figure does not say whether the quality of the code suffers: that is for you to measure.
Three writing agents to start with, then your measurements
Start with three writing agents at most, and go higher when your measurements (module 5) show that integration keeps up, meaning that merging and verifying do not eat the time gained. This three is a starting point, not a measurement: I have no reading that puts it at three rather than four. As long as your measurements say nothing, the extra agents only read: audit, exploration, research.
The argument for the starting point is integration time. Each writing agent produces a branch to merge, then a merged result to verify. Eight agents writing at the same time produce eight branches: the bet of the starting point is that the time gained writing is then lost again integrating. Eight agents that read produce eight reports, which can be compared without breaking anything. With more writing subtasks than the starting point permits, work in waves: three writing agents at most per wave, and the other subtasks wait for the next wave.
Integration keeps up when the time spent merging the branches of a wave and verifying the merged result stays small next to the time the wave saved. Record these two times wave after wave, with a reading like the one module 5 takes over a week. If they show it over several waves, move to four writing agents, then record again.
With several sessions open side by side, the starting point of three writing agents and the maximum of eight that read hold for all sessions together. None of them sees the agents of the others: it is up to you to count them. One exception only: a session that only launches and coordinates its subagents, and whose instructions forbid modifying files, counts neither in the starting point nor in the maximum. It does not work on the code: it distributes the work.
Read-only is written in the instructions ("do not modify any file"). If your tool has permission settings that block writing, commands included, they reinforce it. An agent can ignore its instructions, but it cannot get past a refusal from the tool. Without this block, the ban holds only through the instructions. With it, the ban holds as far as what the tool blocks: an authorised command, a script for example, can still write.
The starting point of three is the one in this module's grid, repeated in the last section. The bounds of the salvo, five and eight, also come from use, not from measurement. The spend, for its part, grows with each agent, whether it reads or writes: it does not set the starting point. Facing someone who disputes this three, your defence is therefore this: it is a starting point, not a measurement, and your own readings move it.
The instructions that lie
Each agent receives instructions, instructions files included, and these instructions contain facts: how many files, which event name, which path, how many tests today. Recount each fact at the moment you write it, and tell the agent what to do if the code contradicts it.
An agent that obeys a false fact produces a defect without displaying a single error. Instructions lie in two ways. They are false from the moment of writing when their author wrote a count without recounting it. They are out of date at the moment of reading when the repository has moved in the meantime. The first is fixed by recounting at the moment of writing. The second only shows by recounting in the repository at the moment of launch: do it, or ask the agent to.
Three rules, to write in your instructions and in your handovers, the documents a session leaves to the next one so that it can take up the work:
- A fact is recounted at the moment it is written, with its command and its date. Written in
the form "N files (
<the command that counts them>, on DD/MM)", the count can be rerun and disputed; without a command, it can only be believed. What was not recounted is written as an assumption: "about, to be checked". - The instructions say what to do when the code contradicts them: follow the code, and report it in the report. An agent that is not asked to dispute its instructions has every reason to obey.
- A handover is dated, and recounted when the work is taken up. Its first paragraph says when its figures were recorded, and with which command.
Action 4: Recount a fact from your last instructions
Open the last instructions you gave to an agent. Take a fact with a number in them, and recount it in the repository with a command. Write the command and today's date next to the fact. If it differs from the instructions, correct them before reusing them. If you find no command that counts it, write "to be checked" next to the fact.
Expected result: The fact, the command that counts it and its date, written side by side; or the words 'to be checked'.
The file lists of criterion 1 are also facts written by an agent: an empty intersection computed on false lists hides an overlap nobody saw.
The grid, on one page
To keep beside the keyboard. It assumes no particular tool; its commands need git and a bash or zsh shell. It also exists on its own, on the grid page.
Will the agents modify files?
├─ no (audit, exploration, research)
│ ──► up to 8 read-only agents, reports reread,
│ if the gain covers the cost (criterion 3); otherwise, only 1;
│ shared database or ports: criterion 1 for them too
└─ yes
▼
Different files, with no shared database or port?
├─ no ──► 1 agent for the subtasks that overlap, one after the other;
│ this group then answers the next questions as one subtask
└─ yes
▼
Does a command judge the result?
├─ no ──► 1 agent for these subtasks, one after the other,
│ and you review each result; this agent counts in the wave
│ (architecture decision: you decide, an agent can prepare)
└─ yes
▼
Does the gain cover the cost, for the whole batch, grouped subtasks included?
├─ no ──► 1 writing agent for the whole batch
└─ yes
▼
One agent per subtask or per group, one worktree each;
3 writing agents at most to start with (a starting point, not a measurement),
and more when your measurements show that integration keeps up;
the next subtasks wait for the next wave, launched from an up-to-date main.
One batch can mix both cases: three writing agents at most to start with, and up to eight that read. The grid gives the number of agents; the regimes table gives the rest of the regime: who writes, and in what order. A single agent is the solo. Several agents writing at the same time, each in its worktree, form a regime the table does not name: solos or duos side by side, in the number the grid sets. A result that goes into a shared branch also takes a reviewer in a fresh session, as in the duo. Five to eight read-only agents that explore form a salvo; fewer than five also form a regime with no name, and follow the same rules: reports reread, and criterion 3. Several read-only agents that look for the defects of a result form an adversarial review. A series of tasks can run as a trio. A long task, where a session would lose the thread, is split into a sequential pipeline.
Three rules go with the grid:
- One worktree per writing agent, as soon as someone else works in the repository at the same
time: another agent, or you. You create it, or the instructions ask the agent to create it. It
is created with
git worktree add <path> -b <branch> main, never with agit checkout -balone. Agit checkout -b, run in the main checkout of the repository (the one where you cloned it, as opposed to the worktrees), changes the current branch of everyone working there. - Commit nothing on
mainwhile a wave is running.mainis the branch the worktrees start from: what you want to put there, commit it before launching the wave. The agents, for their part, commit on their own branch. A commit onmainduring the wave touches files that criterion 1 did not cross-check with those of the wave: the merge can conflict, or break without a conflict. The results of one wave, for their part, have different files, if you checked criterion 1 on the branches. Merge them, then launch the next wave from an up-to-datemain. The trio is an exception, because it has only one writing agent. You can merge the reviewed task, from the main checkout of the repository, while that agent works on the next task in its worktree. Before you merge the branch of that next task intomain, the writing agent first merges the up-to-datemaininto it, from its worktree. - Audit the overlaps before merging, with the command of criterion 1, then rerun the one of criterion 2 on the merged result.
In practice
- Before launching more than one agent, write the verdict of each criterion: per pair for criterion 1, per subtask for criterion 2, for the whole batch for criterion 3.
- For each pair of subtasks you launch at the same time, check that the output of
comm -12is empty, and that they share neither a local database nor a port. For a task that must cover a whole set of files, also check the output ofcomm -23: empty, or limited to files noted as set aside for after integration. - For each subtask you give to an agent, note the command that will judge the result, or "none".
- Start with three writing agents at most at the same time, and go higher only if your measurements show that integration keeps up. For the other agents, check that their instructions forbid them to write and that your tool's settings prevent it when the tool can.
- Date each fact with a number in your instructions, with the command that counted it.
You have just read this module in full, with no account and no payment: it is the product's demonstration.