Claude Code v2.1.319 LLM Gateway Auto Mode Fix: CLAUDE_CODE_AUTO_MODE_SERVER =0
Fix Claude Code v2.1.319 Auto Mode prompts and refused tool calls behind LiteLLM, New API.
Summary
- Claude Code v2.1.319 removed the automatic fallback to the built-in local classifier when running behind an LLM gateway or with telemetry/feature flags.
- Set CLAUDE_CODE_AUTO_MODE_SERVER=0 in your shell or ~/.claude/settings.json to restore unattended Auto Mode execution using the client-side classifier.
- Headless claude -p runs now exit with code 1 instead of 0 when Auto Mode refuses an action due to a missing safety check.
- Enterprise gateway admins can restore free server-side safety checks by upgrading to LiteLLM v1.104.0+ or forwarding the dangerous-tool-use-2026-09-03 beta.
Upgrading to Claude Code v2.1.319 (released November 6, 2026) immediately breaks unattended Auto Mode if you route traffic through a third-party LLM gateway—such as LiteLLM, New API, or sub2api—or if you run with telemetry or feature-flag fetching turned off. Tool calls and shell commands that used to run automatically now stall on interactive permission prompts or get denied outright, and headless claude -p jobs fail with exit code 1.
Anthropic changed the fallback rules in the Claude Code v2.1.319 Changelog:
"Changed auto mode with telemetry or feature flags off, including behind LLM gateways: calls the server can't check are asked about or denied, with no fallback to the built-in classifier; set
CLAUDE_CODE_AUTO_MODE_SERVER=0to keep using it (Bedrock, Vertex and Foundry are unchanged)"
In versions v2.1.278 through v2.1.318, whenever an LLM gateway stripped Anthropic's server-side safety check headers or whenever telemetry was disabled, Claude Code silently fell back to its built-in client-side classifier. Starting in v2.1.319, that automatic fallback is disabled for gateway connections and non-telemetry sessions. If the server does not return a valid safety verdict, Claude Code refuses to guess and blocks the tool call.
On this page
Immediate Fix: Set CLAUDE_CODE_AUTO_MODE_SERVER=0
If you don't control the upstream gateway or need your local sessions and CI pipelines working right away, opt out of the server-side safety check by setting CLAUDE_CODE_AUTO_MODE_SERVER=0. This tells Claude Code to stop waiting for server-side verdicts and evaluate every Auto Mode action using its built-in classifier request. Other changes from the same release week are covered in that week's model and API changes.
To apply the fix for a single terminal session, export the variable before launching claude (setting it inside an already running session has no effect):
export CLAUDE_CODE_AUTO_MODE_SERVER=0
claude
To make the setting permanent across all interactive sessions, IDE extensions, and headless claude -p runs, add it to the env block in your user-level ~/.claude/settings.json:
{
"env": {
"CLAUDE_CODE_AUTO_MODE_SERVER": "0"
}
}
Once you start a new session in Auto Mode, run /status to confirm the active path:
Auto mode server: Disabled
Prior to v2.1.319, /status had a bug where it continued to display Auto mode server: Enabled even when an intermediate LLM gateway was silently dropping the server-side review payload. Version 2.1.319 fixed that status check, so /status now accurately reflects whether server-side verdicts are actually reaching your client.
Note that if you set CLAUDE_CODE_AUTO_MODE_SERVER on a direct Anthropic API connection (without ANTHROPIC_BASE_URL pointed at a gateway), your CLI binary must be at least v2.1.281 for the variable to take effect. Gateway connections have recognized the flag since v2.1.271. For Claude Code with Muse Ember, see configuring Muse Ember in Claude Code.
Why Auto Mode Stopped Falling Back in v2.1.319
When Auto Mode is active, Claude Code evaluates shell commands, file edits outside working directories, and network calls against a safety classifier before executing them. In v2.1.278, Anthropic moved this evaluation to the server side by default (auto-mode-classifier-billing). Instead of the CLI making a separate API call to ask a classifier model whether rm or curl is safe, the safety evaluation happens inside the main /v1/messages inference request on Anthropic's servers.
However, a server-side check can fail in two distinct ways, and v2.1.319 changed how Claude Code handles the first one.
The first case is when the server does not review the session at all. This happens when a proxy or LLM gateway strips the safeguards field from the outgoing request, or when your session has telemetry (DISABLE_TELEMETRY) or feature flags disabled. Up to v2.1.318, Claude Code treated a missing review as a signal to switch over to its built-in classifier. In v2.1.319, behind a gateway or with telemetry/flags off, Claude Code no longer switches to the built-in classifier; it pauses to ask for manual approval or denies the action.
The second case is when the server starts a review but returns no verdict, typically because a reverse proxy cuts off the streaming response early, rewrites the final SSE chunk, or times out. When that happens, Claude Code rejects the unverified tool call and outputs:
The server-side auto mode classifier gave no verdict (timed out), so auto mode cannot determine the safety of <tool>.
If that rejection happens 10 times in a row within a single turn, Auto Mode aborts the turn completely:
Auto mode is unavailable — the server returned no safety verdict for the last 10 responses, so Claude stopped. Send a message to try again, or switch out of auto mode.
Setting CLAUDE_CODE_AUTO_MODE_SERVER=0 fixes both failure modes behind a gateway because Claude Code stops attaching server-side safeguard fields and stops expecting a server verdict in the stream. Every safety check goes straight through a dedicated client-side classifier request over standard /v1/messages.
How CLAUDE_CODE_AUTO_MODE_SERVER=0 Affects Token Billing and Prompts
Switching back to the built-in classifier changes how your account is billed for Auto Mode overhead. You can see the operational differences in the Auto mode classifier billing documentation and the comparison below:
| Behavior / Metric | Server-Side Classifier (Default / 1) |
Built-In Client Classifier (0) |
|---|---|---|
| Where the safety check runs | Inside the main /v1/messages request on the server |
Separate API request issued by the Claude Code client |
| Classifier token billing | Free (no extra classifier token charges) | Billed as standard input/output token usage |
| v2.1.319 gateway behavior if unsupported | Prompts for confirmation or denies tool calls | Works on any standard /v1/messages proxy |
/status indicator |
Auto mode server: Enabled |
Auto mode server: Disabled |
| Eligibility warning prompt | Shown if session unexpectedly falls back | Suppressed when explicitly set to 0 |
When a session on an API or Enterprise account falls back from free server-side review to billed client-side classifier calls (which still happens on direct API connections with telemetry enabled, or on Bedrock, Vertex, and Foundry when a region doesn't support server review), Claude Code halts before the first billable check and prints:
We're changing auto mode to no longer charge for classifier requests in Claude Code. However, this session isn't eligible.
In an interactive terminal, you have to press Enter to accept the token charges (which suppresses the prompt for that gateway on your machine for 24 hours) or Esc to cancel the turn. Explicitly configuring CLAUDE_CODE_AUTO_MODE_SERVER=0 before startup silences this eligibility prompt entirely, which is critical for scripts and background agents that cannot press Enter on stdin. Keep in mind that Anthropic marks CLAUDE_CODE_AUTO_MODE_SERVER as a temporary setting that may be removed in a future release once gateway pass-through support is universal.
Fixes for CI Pipelines and Unattended claude -p Runs in v2.1.319
When I upgraded our automated runner image to v2.1.319, several background claude -p jobs started failing immediately with exit code 1 even though the same scripts had reported green builds on v2.1.318. That happened because v2.1.319 shipped five additional Auto Mode changes alongside the gateway fallback removal.
1. claude -p Now Exits 1 When Safety Checks Are Unavailable
In earlier versions, if a non-interactive claude -p command running in Auto Mode refused a tool call because no safety check was available, the CLI still exited with code 0. Your CI step appeared to succeed even though Claude Code aborted the task halfway through. Version 2.1.319 fixed both text and JSON output modes in claude -p to exit 1 whenever actions are refused due to a missing safety check.
2. Project Settings and Plugins Cannot Re-Enable the Server Check
If you disable the server-side classifier at the user level (~/.claude/settings.json) or via a shell environment variable (CLAUDE_CODE_AUTO_MODE_SERVER=0), v2.1.319 prevents a repository's .claude/settings.json or an installed plugin from flipping CLAUDE_CODE_AUTO_MODE_SERVER back to 1. Once turned off outside the project, it stays off for the entire session.
3. Preventing Unattended Hangs with permissions.denyInsteadOfPrompting
When v2.1.319 encounters a tool call that the server cannot verify—or a command that hits a soft deny rule—it defaults to waiting on an interactive permission prompt. In subagents, teammate sessions, or unattended terminals, waiting on a prompt stalls the worker indefinitely. Version 2.1.319 added the permissions.denyInsteadOfPrompting setting so that any tool call requiring a prompt is immediately denied and the model turn continues:
{
"env": {
"CLAUDE_CODE_AUTO_MODE_SERVER": "0"
},
"permissions": {
"denyInsteadOfPrompting": true
}
}
4. Disabling Feature Flags Without Breaking Telemetry (CLAUDE_CODE_DISABLE_FEATURE_FLAGS)
Many enterprise developers disabled telemetry solely to stop Claude Code from fetching dynamic feature flags at startup, which inadvertently triggered the v2.1.319 Auto Mode restriction. Version 2.1.319 introduced CLAUDE_CODE_DISABLE_FEATURE_FLAGS=1, which stops remote feature-flag fetching and locks every flag to its built-in default without turning off telemetry. Remember that under v2.1.319's rules, turning off feature-flag fetching still disables the automatic classifier fallback, so pair CLAUDE_CODE_DISABLE_FEATURE_FLAGS=1 with CLAUDE_CODE_AUTO_MODE_SERVER=0 if your gateway does not support server-side reviews.
5. Forcing Server-Side Review When CLAUDE_CODE_DISABLE_EXPERIMENTAL_BETAS=1 Is Set
Teams routing through strict gateways often set CLAUDE_CODE_DISABLE_EXPERIMENTAL_BETAS=1 to avoid HTTP 400 invalid beta flag errors, alongside environment flags like CLAUDE_CODE_DISABLE_ULTRATHINK=1 from v2.1.316 or Mantle gateway assume_role settings from v2.1.318. Previously, setting CLAUDE_CODE_DISABLE_EXPERIMENTAL_BETAS=1 had the side effect of disabling server-side Auto Mode checks behind gateways. In v2.1.319, setting CLAUDE_CODE_AUTO_MODE_SERVER=1 explicitly turns on the server-side check behind an LLM gateway even when CLAUDE_CODE_DISABLE_EXPERIMENTAL_BETAS=1 is present. If your organization enforces CLAUDE_CODE_DISABLE_EXPERIMENTAL_BETAS=1 inside managed settings (managed-settings.json), CLAUDE_CODE_AUTO_MODE_SERVER=1 must also be declared inside those same managed settings to take effect.
Why AWS Bedrock, Google Vertex AI, and Microsoft Foundry Are Unchanged
The v2.1.319 release notes explicitly state that (Bedrock, Vertex and Foundry are unchanged). If you connect directly to Amazon Bedrock, Google Cloud Vertex AI (Agent Platform), or Microsoft Foundry using Claude Code's native provider integrations rather than a generic ANTHROPIC_BASE_URL proxy, you do not need to change your configuration.
In these host-managed environments, the integration layer sets CLAUDE_CODE_PROVIDER_MANAGED_BY_HOST internally and communicates over provider-native SDK contracts rather than raw proxy headers. For example, Amazon Bedrock's InvokeModel API passes beta flags inside the JSON payload's anthropic_beta array instead of an HTTP anthropic-beta header that a corporate reverse proxy might scrub. Because these managed cloud transports have a known, fixed contract with Anthropic's runtime:
- Setting
CLAUDE_CODE_DISABLE_EXPERIMENTAL_BETAS=1on Bedrock, Vertex AI, or Foundry does not stop server-side Auto Mode queries (unlike direct API connections). OnlyCLAUDE_CODE_AUTO_MODE_SERVER=0opts out. - If a specific cloud region or credential set on Bedrock, Vertex AI, or Foundry does not yet return a server-side review, Claude Code v2.1.319 still falls back to the built-in classifier (and displays the standard classifier billing notice) instead of blocking the tool call.
How Gateway Admins Can Support Free Server-Side Auto Mode
Having every developer set CLAUDE_CODE_AUTO_MODE_SERVER=0 works as an immediate workaround, but it means your organization pays token charges for every built-in classifier call. To get free server-side Auto Mode working through your own LLM gateway on v2.1.319, your proxy must implement feature pass-through according to the Claude Code LLM Gateway Protocol.
When Claude Code initiates a server-side Auto Mode turn, it attaches two items to the outgoing /v1/messages request:
- The
anthropic-betaHTTP Header: The header must include the valuedangerous-tool-use-2026-09-03. If your gateway overwritesanthropic-betawith a static string or strips unknown beta tokens, the upstream server will ignore the safety check. - The
safeguardsRequest Body Field: Your gateway must not strip unrecognized top-level JSON keys when validating the request schema. It must forward thesafeguardsarray verbatim:
{
"model": "claude-sonnet-4-5-20250929",
"max_tokens": 8192,
"safeguards": [
{
"type": "dangerous_tool_use",
"mode": "auto"
}
],
"messages": [...]
}
Both anthropic-beta: dangerous-tool-use-2026-09-03 and the safeguards array must arrive at the upstream API together; if either one is dropped, no server review takes place.
On the return path, the upstream API embeds the safety verdict inside the final message_delta event of the Server-Sent Events (SSE) stream. Your gateway must pass the safeguard_results property inside delta back to the client without truncation:
{
"type": "message_delta",
"delta": {
"stop_reason": "tool_use",
"stop_sequence": null,
"safeguard_results": [
{
"type": "dangerous_tool_use",
"status": {
"type": "available",
"tool_uses": {
"toolu_01AbcDefGhiJklMno": {
"status": "evaluated",
"result": "not_flagged"
}
}
}
}
]
}
}
Pay close attention to the "toolu_01AbcDefGhiJklMno" key inside tool_uses. The server indexes its verdict by the exact tool_use_id generated in the assistant's response. If your gateway rewrites, prefixes, or regenerates tool_use_id values during stream serialization, Claude Code will not find a matching ID in safeguard_results and will treat the action as unverified.
Here is how current gateway releases handle this protocol:
- LiteLLM: Upgrade your proxy deployment to LiteLLM v1.104.0 or newer. LiteLLM added native pass-through for
safeguardsrequest bodies andsafeguard_resultsstreaming deltas in v1.104.0. Once upgraded, your developers can removeCLAUDE_CODE_AUTO_MODE_SERVER=0(or setCLAUDE_CODE_AUTO_MODE_SERVER=1) and/statuswill reportAuto mode server: Enabled. - New API, One API, and sub2api: Most builds of these relays deserialize incoming
/v1/messagespayloads into fixed Go or Node structs and drop unknown fields likesafeguardsbefore forwarding upstream (in addition to group routing rules like sub2api/v1/messagesdispatch blocks). When using these relays with Claude Code v2.1.319, keep"CLAUDE_CODE_AUTO_MODE_SERVER": "0"in~/.claude/settings.json. If you want to inspect which local commands will trigger a classifier call under that setup, runclaude auto-mode configorclaude auto-mode defaultsin your terminal to print the activeallow,soft_deny, andhard_denyJSON rules.