Claude Code Subagent Limits: Spawn Cap, Concurrency, and Nesting Depth#
Published by Alex Sorokoletov
Claude Code stops spawning subagents when a session hits one of three caps: 200 spawns per session, 20 running at once, and a nesting depth of 3. Each cap has an environment variable that raises or lowers it: CLAUDE_CODE_MAX_SUBAGENTS_PER_SESSION, CLAUDE_CODE_MAX_CONCURRENT_SUBAGENTS, and CLAUDE_CODE_MAX_SUBAGENT_SPAWN_DEPTH. When a cap is reached, Claude Code tells the model to finish the work directly instead of launching more agents.[1]
The three caps#
| Cap | Environment variable | Default | Resets |
|---|---|---|---|
| Spawns per session | CLAUDE_CODE_MAX_SUBAGENTS_PER_SESSION | 200 | /clear |
| Running at once | CLAUDE_CODE_MAX_CONCURRENT_SUBAGENTS | 20 | As agents finish |
| Nesting depth | CLAUDE_CODE_MAX_SUBAGENT_SPAWN_DEPTH | 3 | Per branch |
The three are separate. A run can stay well under the concurrency cap and still hit the per-session total, or launch few agents that each nest too deep. Each cap raises a different message and names its own variable.
Set the caps#
All three read from the environment, so set them in the env block of settings.json to apply them to every session, or export them in the shell for one run.
{
"env": {
"CLAUDE_CODE_MAX_SUBAGENTS_PER_SESSION": "500",
"CLAUDE_CODE_MAX_CONCURRENT_SUBAGENTS": "40",
"CLAUDE_CODE_MAX_SUBAGENT_SPAWN_DEPTH": "5"
}
}
Use ~/.claude/settings.json for every project, or .claude/settings.json for one project. Restart Claude Code after the change.
Spawn limit reached: CLAUDE_CODE_MAX_SUBAGENTS_PER_SESSION#
This is a per-session count of how many subagents the session has started, capped at 200 by default. It counts spawns over the whole session, not agents running now, so a long run that fans out in waves can reach it even when few agents run at any moment. When the count is reached, Claude Code tells the model to complete the remaining work with its own tools instead of spawning more, and to ask you to raise the variable if more agents are genuinely needed.
/clear resets the budget, because it starts a new session. Raising CLAUDE_CODE_MAX_SUBAGENTS_PER_SESSION raises the ceiling for runs that legitimately delegate in large numbers, such as a workflow that maps one agent per file across a big tree. The cap exists to stop a delegation loop from spawning agents without end, so raise it when you know the work is bounded, not to paper over a loop.
This cap arrived in v2.1.212, published July 16, 2026.[2]
Concurrent limit reached: CLAUDE_CODE_MAX_CONCURRENT_SUBAGENTS#
This caps how many subagents run at the same time, default 20. It stops one message from fanning out into an unbounded set of background agents. When the cap is reached, the attempt to launch is refused with:
Concurrent subagent limit reached. You can run N subagents at once. Do not retry. If the user wants more concurrent subagents, ask them to increase CLAUDE_CODE_MAX_CONCURRENT_SUBAGENTS.
Unlike the per-session cap, this one clears on its own: as running agents finish, slots free up and new agents launch. Raise CLAUDE_CODE_MAX_CONCURRENT_SUBAGENTS when your machine and plan can handle more agents at once, and lower it to hold down token burn and memory from parallel runs. The cap is governed by a feature flag, so a given account may not have it on.
This cap arrived in v2.1.217, published July 21, 2026.[3]
Nesting limit reached: CLAUDE_CODE_MAX_SUBAGENT_SPAWN_DEPTH#
This caps how deep delegation can nest: a subagent spawning its own subagent, and so on. The default is 3. When a spawn would go past the cap, it is refused with:
Subagent nesting limit reached (depth X of Y). Complete this task directly using your tools instead of spawning another agent. If the user explicitly requested deeper nesting, ask them to raise CLAUDE_CODE_MAX_SUBAGENT_SPAWN_DEPTH.
Set CLAUDE_CODE_MAX_SUBAGENT_SPAWN_DEPTH=1 to turn nesting off, so subagents cannot spawn their own subagents and the team roster stays flat. Set a higher number to allow deeper trees. The default changed over two releases: v2.1.217 set it to 1, so nesting was off by default, and v2.1.219 raised it to 3.
Timeline#
| Version | Published | Change |
|---|---|---|
| v2.1.212 | 2026-07-16 | Per-session spawn cap added, default 200, CLAUDE_CODE_MAX_SUBAGENTS_PER_SESSION. /clear resets the budget. |
| v2.1.217 | 2026-07-21 | Concurrency cap added, default 20, CLAUDE_CODE_MAX_CONCURRENT_SUBAGENTS. Nesting default set to 1 (off), CLAUDE_CODE_MAX_SUBAGENT_SPAWN_DEPTH. |
| v2.1.219 | 2026-07-24 | Nesting default raised to 3; set CLAUDE_CODE_MAX_SUBAGENT_SPAWN_DEPTH=1 to disable nesting. |
Which limit am I hitting?#
Read the message. "Concurrent subagent limit reached" is the concurrency cap, and it clears as agents finish, so a brief wait or a smaller fan-out gets past it. "Subagent nesting limit reached (depth X of Y)" is the depth cap, raised by a subagent trying to spawn one more level down. A message about completing the work directly because the session has started too many agents is the per-session cap, and only /clear or a higher CLAUDE_CODE_MAX_SUBAGENTS_PER_SESSION clears it within a run.
Should you raise them?#
Keep the defaults unless a real workload needs more. The caps are guardrails against runaway delegation, not performance throttles you are meant to tune away. Raise the per-session cap for a bounded batch job that maps one agent per item across a large set. Raise the concurrency cap when your hardware and plan can absorb more parallel agents and you want the fan-out to finish sooner. Raise the depth cap only when a plan genuinely needs agents that delegate further, and remember each extra level multiplies the agents and the tokens.
FAQ#
Q: What does "Concurrent subagent limit reached" mean in Claude Code?
A: The session already has the most subagents running that Claude Code allows at once, 20 by default. It clears as running agents finish. Raise it with CLAUDE_CODE_MAX_CONCURRENT_SUBAGENTS.
Q: How do I raise the subagent spawn limit?
A: Set CLAUDE_CODE_MAX_SUBAGENTS_PER_SESSION to a higher number in the env block of ~/.claude/settings.json, then restart Claude Code. The default is 200 spawns per session.
Q: What resets the per-session subagent budget?
A: /clear, because it starts a new session. The per-session cap counts every subagent the session has started, so it does not fall as agents finish, unlike the concurrency cap.
Q: What is CLAUDE_CODE_MAX_SUBAGENT_SPAWN_DEPTH?
A: The cap on how deep subagents can nest, default 3. Set it to 1 to stop subagents from spawning their own subagents, or higher to allow deeper trees.
Q: Why did a subagent stop and tell me to finish the work directly?
A: It hit one of the caps: the per-session spawn total, the concurrent cap, or the nesting depth. The message names the variable that raises the one you hit.
Q: Do these variables go in settings.json or the shell?
A: Either. They read from the environment, so the env block of settings.json applies them to every session, and a shell export applies them to one run.
Q: Which versions added the subagent caps?
A: The per-session cap in v2.1.212 (July 16, 2026), the concurrency cap and the depth cap in v2.1.217 (July 21, 2026), with the depth default raised from 1 to 3 in v2.1.219 (July 24, 2026).
Sources: [1] Claude Code changelog | [2] Claude Code changelog, v2.1.212 | [3] Claude Code changelog, v2.1.217
Related: CLAUDE_CODE_MAX_SUBAGENTS_PER_SESSION in the env-var glossary | CLAUDE_CODE_MAX_CONCURRENT_SUBAGENTS | CLAUDE_CODE_MAX_SUBAGENT_SPAWN_DEPTH | Claude Code v2.1.217 analysis | Context Window Management Guide