Claude Code 2.1.212: Subagent Caps, MCP Auto-Background, and Prompt Caching Fixed on Custom Gateways

Version 2.1.212 adds configurable per-session limits on subagent spawns and WebSearch calls, auto-backgrounds long MCP tool calls, and restores prompt caching through custom API gateways and Bedrock/Vertex.

Published via Anthropic Claude Code

Archive item produced with AI assistance from the cited source and published without individual review. Editor of record: Joe Werner.

Abstract routing diagram showing session governance controls and agent delegation limits

The governance gap that let Claude Code sessions spawn unlimited subagents and fire unlimited web searches is now closed. Version 2.1.212, released this week, adds two hard session limits that operators can tune, automatically moves long MCP tool calls to the background, and fixes prompt caching for teams running custom API gateways or Bedrock/Vertex endpoints.

Here is what changed and why it matters for engineering teams running Claude Code at scale.

What happened

Anthropic shipped Claude Code 2.1.212 with four operator-relevant changes alongside a large batch of stability fixes:

  1. Subagent spawn cap — Default 200 subagents per session. Override with CLAUDE_CODE_MAX_SUBAGENTS_PER_SESSION. /clear resets the budget.
  2. WebSearch session limit — Default 200 tool calls per session. Override with CLAUDE_CODE_MAX_WEB_SEARCHES_PER_SESSION. Prevents runaway search loops in long-horizon agentic runs.
  3. MCP auto-background — MCP tool calls that run longer than 2 minutes now move to the background automatically so the session stays usable. Configurable via CLAUDE_CODE_MCP_AUTO_BACKGROUND_MS (or set to 0 to disable).
  4. Prompt caching fixed on custom gateways — The mid-conversation system block now correctly works behind LLM gateways and custom base URLs, including Bedrock and Vertex AI.

Additionally, /fork now copies a conversation into a new background session (its own row in claude agents), rather than launching an in-session subagent. Teams that depend on /fork for parallel work should note the behavioral change: the former in-session subagent behavior is now /subtask.

There are also two security-relevant bug fixes:

  • Plan mode Bash commands — A bug allowed Claude Code's plan mode to auto-run file-modifying Bash commands (touch, rm, etc.) without a permission prompt or SDK canUseTool callback. This is now fixed.
  • Worktree symlink escape — A bug let worktree creation follow a repository-committed symlink at .claude/worktrees to create files outside the repository. Also fixed.

Why it matters for AI engineering teams

Runaway agent governance is the central change. When Claude Code runs multi-agent workflows — parallel subagents, recursive agent spawning, deep research loops with web search — unbounded session activity translates directly into unbounded API cost and unpredictable completion time.

Prior to 2.1.212, there was no platform-level mechanism to cap how many subagents a session could spawn or how many web searches it could fire. Teams had to rely on application-layer accounting or budget injection in system prompts, both of which fail when an agent escapes its expected workflow.

The new env-var caps give operators a configurable floor. The defaults (200 for each) are generous enough not to interrupt typical workflows but tight enough to prevent runaway exponential spawning. For operators running Claude Code through a gateway — where cost visibility arrives with latency — this is a first-order reliability control.

The MCP auto-background change addresses a different failure mode: long-running MCP tool calls that previously blocked the session. For operators who route MCP calls through slow external services (document processors, database queries, long-running orchestration calls), the 2-minute auto-background threshold prevents sessions from appearing hung. Teams that need deterministic behavior — or that want to disable this for debugging — can set CLAUDE_CODE_MCP_AUTO_BACKGROUND_MS=0.

The router/operator angle

The prompt caching fix is the most quietly significant change for gateway operators. The mid-conversation system block — which allows Claude Code to inject context mid-turn without burning cache — was silently not working for teams routing through custom base URLs. That includes:

  • Operators running Claude through a self-hosted AI gateway (e.g., LiteLLM proxy, TheRouter, Azure AI Foundry custom endpoint)
  • Teams using Bedrock or Vertex AI with custom base URL overrides
  • Enterprise deployments where ANTHROPIC_BASE_URL points to an internal proxy

Before this fix, those setups incurred full re-processing cost on every mid-conversation system message. The fix restores expected caching behavior. If you noticed higher-than-expected token costs on gateway-routed Claude Code sessions, upgrading to 2.1.212 should reduce them.

For the /fork rename: if your team has shell scripts, CI pipelines, or automation that triggers /fork expecting a contained in-session subagent, those workflows now create a separate background session instead. Audit any automation that relied on the old /fork behavior and migrate to /subtask for the in-session pattern.

The plan mode Bash fix matters for headless operator deployments where Claude Code runs unattended in CI/CD pipelines. The pre-fix behavior — auto-executing destructive file operations without permission — was a real risk surface for automated deployments. Operators running Claude Code in plan mode should confirm they are on 2.1.212 or later.

What to watch or try now

  • Tune the caps to your baseline: run a production session with CLAUDE_CODE_MAX_SUBAGENTS_PER_SESSION=50 and CLAUDE_CODE_MAX_WEB_SEARCHES_PER_SESSION=50 for a week to understand your typical session budget, then adjust.
  • Audit /fork usage: search for /fork in team playbooks, scripts, and CI configs. Replace with /subtask for in-session patterns.
  • Verify prompt caching on your gateway: after upgrading, compare token usage on gateway-routed sessions with what you observe on direct API sessions. The diff should narrow.
  • Check MCP service latency: if you have MCP integrations that regularly run >2 minutes, test whether auto-background affects your workflow assumptions.
  • Review plan mode deployments: confirm that any headless Claude Code pipelines using plan mode now correctly gate on canUseTool before Bash execution.

For teams routing Claude Code through a custom API gateway, the 2.1.212 changes — especially the prompt caching fix and subagent caps — are worth scheduling an upgrade window for this sprint.

Help & contact