CLAUDE_CODE_MAX_WEB_SEARCHES_PER_SESSION
A Claude Code environment variable, read out of the shipped bundle. It has been in the build since v2.1.212, including the newest one read.
What it is
Cap on the total number of [WebSearch](/docs/en/tools-reference#websearch-tool-behavior) calls one session can make (default: 200). When Claude reaches the cap, further WebSearch calls return a notice telling it to continue with the information it already gathered. Accepts a positive whole number with no upper bound. Anything else is ignored and the default applies, so the cap can be raised but not turned off. Requires Claude Code v2.1.212 or later
Anthropic's own wording. Read off Environment variables, captured 2026-08-28.
Presence across releases
| Releases | Reading | Declared type | Default |
|---|---|---|---|
| 2.1.245 – 2.1.250 5 releases | never mined | — | — |
| 2.1.212 – 2.1.243 31 releases | in the build | int | — |
A row reading never mined is a release with no archived bundle behind it. Nothing was read out of it, so nothing here says whether the name was in it. A declared type or a default is only ever what that release's own bundle stated.
Changelog entries naming it
No changelog entry here has ever named it. That is a statement about what has been written, not about the name: it has been in the build since v2.1.212 without anybody writing a line about it.
Documentation pages
- Environment variables reference table Claude Code CLI
- Claude Code changelog mentions it Claude Code CLI
- Tools reference mentions it Claude Code CLI
A reference table page is one whose own table defines this name, and it is where the description above came from. A page that mentions it carries the name somewhere in its text and may say nothing about it at all. Every page carrying it.
Names beside it
Every environment variable in the inventory starting claude_code_max, up to twelve of them.
CLAUDE_CODE_MAX_CONCURRENT_SUBAGENTSHow many [subagents](/docs/en/sub-agents#concurrent-subagent-limit) can be running in one session before the Agent tool refuses to spawn another (default: 20). Accepts a positive whole number in plain digits; anything else is ignored, so the variable can adjust the cap but can't disable it. Requires Claude Code v2.1.217 or later 2.1.217
CLAUDE_CODE_MAX_CONTEXT_TOKENSOverride the context window size Claude Code assumes for the active model. As of v2.1.193, how it applies depends on how Claude Code resolves the model ID; see [Correct the window for a gateway or custom model ID](/docs/en/model-config#correct-the-window-for-a-gateway-or-custom-model-id). Use this when routing to a model through ANTHROPIC_BASE_URL whose context window does not match the built-in size for its name 2.1.138
CLAUDE_CODE_MAX_OUTPUT_TOKENSSet the maximum number of output tokens for most requests. Defaults and caps vary by model; see [max output tokens](https://platform.claude.com/docs/en/about-claude/models/overview#latest-models-comparison). Claude Code defaults to 32000 for model IDs it doesn't recognize, such as gateway-specific names, and lowers values above a model's cap to the cap. Increasing this value reduces the effective context window available before [auto-compaction](/docs/en/costs#reduce-token-usage) triggers 2.1.138
CLAUDE_CODE_MAX_RETRIESOverride the number of times to retry failed API requests (default: 10). Capped at 15 as of v2.1.186; as of v2.1.199, CLAUDE_CODE_RETRY_WATCHDOG raises the default and removes the cap. For unattended sessions that need to wait through longer outages, set CLAUDE_CODE_RETRY_WATCHDOG instead 2.1.138
CLAUDE_CODE_MAX_SUBAGENT_SPAWN_DEPTHNumber of [subagent layers](/docs/en/sub-agents#let-subagents-spawn-their-own-subagents) allowed below the main conversation (default: 3). At the default, subagents can spawn their own subagents, and a subagent at the third layer can't spawn further; set 1 to turn nesting off. In v2.1.217 through v2.1.218, the default was 1, so a subagent couldn't spawn its own unless you raised the limit; v2.1.219 raised the default to 3. Accepts a positive whole number in plain digits; anything else is ignored, so the limit can be adjusted but not removed. Requires Claude Code v2.1.217 or later 2.1.217
CLAUDE_CODE_MAX_SUBAGENTS_PER_SESSIONRemoved in v2.1.224 and now a no-op. Previously capped the total number of [subagents](/docs/en/sub-agents) Claude could spawn with the Agent tool in one session (default: 200); spawning past the cap failed with Subagent spawn limit reached. The [concurrent subagent limit](/docs/en/sub-agents#concurrent-subagent-limit) and the [depth limit](/docs/en/sub-agents#let-subagents-spawn-their-own-subagents) still apply 2.1.212
CLAUDE_CODE_MAX_TOOL_USE_CONCURRENCYMaximum number of read-only tools and subagents that can execute in parallel (default: 10). Higher values increase parallelism but consume more resources 2.1.138
CLAUDE_CODE_MAX_TURNSCap the number of agentic turns when no explicit limit is passed. Equivalent to passing [--max-turns](/docs/en/cli-reference#cli-flags), which takes precedence when both are set. A value that is not a positive integer is rejected at startup with an error rather than treated as no cap 2.1.139
Read out of the published npm bundle release by release, and out of Anthropic's own documentation as this site captured it. Nothing on this page is a description anybody here wrote about what the environment variable does. All environment variables.