Skip to content
Mastering Claude

Home / Several agents and adversarial checking

Several agents and adversarial checking8 minApplication

Isolating and running in the background: worktrees and the dry loop

A git worktree per agent stops the files of several parallel agents from colliding, a dry loop repeats until a cycle no longer returns anything new, judged against an already seen set, and since 13 August 2026 a non teammate agent launched during an interactive session runs in the background by default with a notification at the end rather than blocking the session.

An agent that writes into the same repository as another agent, at the same time, risks overwriting what the other has just produced. The fix documented by Claude Code is to give each parallel agent its own temporary copy of the repository, a git worktree, by adding isolation: worktree to its configuration header. Each agent then works in its own copy, and this copy cleans itself up automatically when the agent has made no changes.

A loop that knows when to stop

A second move answers a different problem, a search that does not know when it has finished finding things. The official documentation describes this pattern for spotting flaky tests: rerun the suite several times, note which tests fail intermittently, and stop as soon as two consecutive runs no longer flag anything new. The same principle applies to any exhaustive search, a dependency audit, an inventory of orphan files: each cycle compares its result against the set already known, and only an item missing from that set counts as new for that round.

Cycle 1 : 4 elements trouves, 4 nouveaux, ensemble connu = 4
Cycle 2 : 5 elements trouves, 1 nouveau, ensemble connu = 5
Cycle 3 : 5 elements trouves, 0 nouveau
Cycle 4 : 5 elements trouves, 0 nouveau, deux tours sans nouveaute, la boucle s'arrete

The change of 13 August 2026

The switch to background running is not a setting you turn on, it has become the default behaviour. Since Claude Code version 2.1.232, released on 13 August 2026, an agent that is not a teammate of the session and starts during an interactive session runs in the background instead of blocking the ongoing conversation; the changelog does not say whether it gives a notification at the end, that point still needs checking independently. The same changelog places this change in the same entry as the default activation of the mode that makes a subagent inherit the cache and the full conversation, joined by a plain and: it establishes no causal link between the two, these are two simultaneous changes in the same version, not one mechanism triggering the other.

Worktree isolation and background execution combine naturally: several agents launched in parallel, each in its own copy of the repository, now run without blocking the session while they work. The previous lesson on choosing the architecture determines whether these agents should be launched in parallel, this one determines how to make them coexist without colliding. The next lesson deals with what happens once their number goes beyond a handful.

One detail changes how reliable the dry loop is: the count of new items is calculated against the set accumulated since the very first cycle, never against just the previous cycle. An item that disappears then reappears in the following cycle must not be recounted as new, or the loop risks running indefinitely on an unstable result rather than on a search that is genuinely incomplete.

Figure 1

The default switch to background running, exact date

2.1.232Claude Code version
from which a non teammate agent launched during an interactive session runs in the background by default
Claude Code, changelog, 2026-08-13
The change concerns non teammate agents launched during an interactive session, not every agent launch in every circumstance.
Figure 2

The dry loop, cycle by cycle

01
Run the cycle
The cycle reruns the same search against the current state of the observed system.
02
Compare against what is already known
Each item found is compared against the set accumulated since the very first cycle, not just the previous cycle.
03
Count what is new
Only an item missing from this accumulated set counts as new for this round.
04
Decide
If this round contains at least one new item, a new cycle starts straight away.
05
Stop
After two consecutive rounds with nothing new at all, the loop stops and the accumulated set becomes the result kept.
Each cycle reruns the same search and compares its result against the set already known, the loop only stops after two consecutive rounds with nothing new.
Calibrate it yourself

A developer launches two agents at the same time from an interactive session, each tasked with applying the same dependency migration in a different folder of the same repository, with worktree isolation turned on in each agent's header.

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

What to remember
  • A worktree per agent gives each parallel agent its own temporary copy of the repository, which stops two agents from writing to the same place at the same time.
  • A worktree that has been used for no change cleans itself up on its own, with no manual step.
  • A dry loop compares each cycle against the set accumulated since the first round, and stops after two consecutive rounds with nothing new.
  • The default switch to background running, since version 2.1.232, only concerns non teammate agents launched during an interactive session, not every agent launch, and is not presented by the changelog as the consequence of another change in the same entry.
Do this now

Open the configuration of your next parallel subagent and add isolation: worktree to its header, then launch it alongside another agent on the same repository to check that neither one touches the other's files.

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 Claude Code changelog to see whether a number later than 2.1.232 changed the condition that triggers the switch to background running, in particular the scope of the mode that makes a subagent inherit the full conversation.
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.