Skip to content
Mastering Claude

Home / Several agents and adversarial checking

Several agents and adversarial checking8 minApplication

Making a large scale fan-out hold together

A bulky deliverable handed to a single agent gets cut off by an output size limit with nothing written at all: split by axis, have each agent write to its own file, respect the documented cap of sixteen agents active at once and one thousand agents in total on a single run, a single call accepting up to 4,096 items that the runtime itself schedules under that cap, then verify by comparing the expected files against what actually exists on disk rather than taking the agents' word for it.

A single agent tasked with writing an over-long deliverable gets interrupted by an output size limit, and nothing gets written to disk: the task looks impossible when the real problem lies in the splitting. The fix fits in one sentence, one agent per axis, each writing its own file, so that the limit only ever bears on a single file at a time rather than on the whole deliverable.

The documented cap

Claude Code caps the number of agents active at the same time at sixteen, a figure that drops if the machine has fewer processors available, including inside a container with a limited number of cores. A second cap, distinct from the first, limits the total number of agents launched across an entire run to one thousand, precisely to stop a runaway loop from launching agents endlessly. These two counters must not be confused: the first bounds what is running at a given instant, the second bounds the cumulative total over the whole duration of the work. A third figure changes the practical picture: a single parallel() or pipeline() call accepts up to four thousand and ninety six items, and the runtime itself schedules them under the cap of sixteen, with no manual step, a longer submission being simply rejected with an error rather than silently truncated. Splitting manually into successive waves, each wave checked before the next one starts, keeps its use, but as a choice for verifying the work in batches rather than as the only way to stay under the concurrency cap.

Verify the disk, not the report

An agent that claims to have written its file can be wrong, about its own output path or about the content actually produced. The discipline that closes the loop is to write, before launching the fan-out, the exact list of expected files, then compare it afterwards against what genuinely exists on disk, never against the reports the agents themselves send back.

# liste attendue, écrite avant le lancement
cat > attendus.txt < obtenus.txt
diff attendus.txt obtenus.txt

One last reflex saves budget on a large volume of similar calls that do not need an immediate answer. The Batch API processes this kind of work asynchronously with a fifty percent discount on token cost, on a rate quota separate from live calls. It suits a fan-out that is already written and ready to run in one go, not work where each step depends on the result of the one before.

These three disciplines combine in the reverse order of their discovery. You first isolate each agent in its own worktree, then respect the concurrency cap through waves, and finally verify on disk what the fan-out actually produced, never what the agents said about it.

Figure 1

Two distinct caps on a fan-out

16agents active at once
concurrency cap documented by Claude Code, drops with fewer processors available
Claude Code, workflows documentation, 2026-09-02
1000agents in total
cumulative cap on a single run, to stop a runaway loop
Claude Code, workflows documentation, 2026-09-02
The first cap bounds what is running at the same instant, the second bounds the cumulative total over the whole duration of the work, two different counters in the same table.
Figure 2

A fan-out checked in waves, a choice and not an obligation

01
Write the expected list
Before any launch, the exact list of files the fan-out must produce is written into a separate file.
02
Launch a wave
A group of agents not exceeding the documented concurrency cap starts at the same time, each on its own output file.
03
Verify on disk
The expected list is compared against the actual content of the output folder, never against the reports the agents send back.
04
Launch the next wave
Once the previous wave is verified complete, a new wave starts on the remaining expected files.
05
Stop
The last wave finishes when the expected list and the actual content of the folder match exactly.
The runtime already schedules the whole set under the concurrency cap in a single call; splitting into waves stays useful for checking the work in batches before continuing.
Calibrate it yourself

A coordinator launches twenty four agents in a single go, each tasked with writing the sheet for a different product in the catalogue, every agent instructed to write its result into a separate file named after the product.

Write in one sentence what this situation establishes, and in one sentence what it does not establish.

What to remember
  • A single agent tasked with writing an over-long deliverable gets interrupted by an output size limit, and nothing gets written to disk until the splitting by axis and by file has been done.
  • The cap of sixteen agents active at once and the cap of one thousand agents in total on a single run are two distinct counters, one for the present instant, the other for the cumulative total.
  • A single parallel() or pipeline() call accepts up to 4,096 items and the runtime schedules them itself under the concurrency cap; splitting into waves stays useful for checking the work in batches, not for respecting the cap, which the runtime already respects.
  • The list of expected files, written before the fan-out is launched, is compared against the actual content of the output folder, never against the reports the agents send back.
Do this now

Before your next fan-out of more than a handful of agents, write the exact list of files you expect into a file, launch the fan-out, then compare that list against the actual content of the output folder before trusting any agent's report.

What still needs checking

These points depend on an interface or a rule that may have changed since this was written. Check them on your own screen before relying on them.

  • Check the current Claude Code documentation to see whether the cap of sixteen concurrent agents has changed since this lesson was written, this cap depends on the number of processors available on the machine running it.
Check the source

Every datable claim in this lesson links here to the public text behind it. A source that does not open proves nothing.