[BUG] Auto mode classifier builds 5 cache_control blocks → API 400, surfaced as "<model> is temporarily unavailable" (regression 2.1.220 → 2.1.222)

Status Open
Reported on v2.1.222
Maintainer reply None cached
Activity 2 comments · opened Aug 7, 2026

Preflight Checklist

  • [x] I have searched existing issues and this hasn't been reported yet
  • [x] This is a single bug report (please file separate reports for different bugs)
  • [x] I am using the latest version of Claude Code

What's Wrong?

Since 2.1.222, auto mode denies every Bash/Edit action when the working directory has a
CLAUDE.md. The visible message says a model is temporarily unavailable, which sends you
looking at quota and provider status. The debug log shows something else entirely: the auto
mode classifier request carries 5 blocks with cache_control — one more than the API allows —
so it is rejected with 400 invalid_request_error. The CLI then retries with a fallback model,
which builds the same oversized request and 400s again, and auto mode fails closed.

So the action is not denied because a model is unavailable; it is denied because the request
the CLI itself constructed is invalid. Both models were reachable the whole time.

This is a regression. Same directory, same settings, same command: 2.1.220 works, 2.1.222
does not.

What Should Happen?

Two things:

  1. The classifier request should stay within the 4-block cache_control limit, so auto mode

keeps working in a directory that has CLAUDE.md / project memory context.

  1. A 400 invalid_request_error should not be surfaced as "<model> is temporarily

unavailable". That wording points at capacity, quota and provider health, none of which
were involved — it cost me most of a day. Reporting the real error kind (or even just
"classifier request rejected: <message>") would make this self-diagnosing.

Error Messages/Logs

[WARN] [Stall] classifier_request_finished ... stage=xml_s1 outcome=error errorKind=Error:400
[WARN] Auto mode classifier (XML) error: 400 {"type":"error","error":{"type":"invalid_request_error","message":"A maximum of 4 blocks with cache_control may be provided. Found 5."}}
[WARN] Got error trying Sonnet 5 as auto mode classifier, using claude-opus-5[1m]
[WARN] Auto mode classifier unavailable, denying with retry guidance (fail closed)

User-visible message:
claude-opus-5[1m] is temporarily unavailable, so auto mode cannot determine the safety of
Bash right now.

Model names carry a [1m] suffix because this setup points ANTHROPIC_BASE_URL at a
gateway whose aliases include it. The 400 is the standard Anthropic API cache_control
limit, so it should be provider-independent.

Steps to Reproduce

  1. Work in a directory that has a CLAUDE.md (any content). This matters: an empty directory

such as /tmp does NOT reproduce, presumably because the extra cached context block is
what pushes the request from 4 to 5.

  1. Put the session in auto permission mode.
  1. Ask for a Bash command that is OUTSIDE the built-in read-only set, so the classifier is

actually the gate:

claude --permission-mode auto -p 'Use the Bash tool to run exactly: ln -sf /etc/hostname /tmp/x'

Do not test with echo/ls/cat — those are allowed without ever consulting the classifier,
so they succeed even while auto mode is broken and make the bug look absent.

  1. The action is denied with the "temporarily unavailable" message. To see the real cause:

CLAUDE_CODE_DEBUG_LOGS_DIR=/tmp/dbg claude --debug --permission-mode auto -p '...'

then grep the log for classifier_request. In VS Code the extension already runs with
--debug, so the same lines are in its output log.

  1. A/B on the same directory and command:

npx -y @anthropic-ai/claude-code@2.1.220 -> classifier outcome=ok, action runs
2.1.222 -> classifier 400 "Found 5", action denied

Session size is irrelevant: it reproduces on a brand-new session (15 transcript entries) and
on a long one alike.

Claude Model

Opus

Is this a regression?

Yes, this worked in a previous version

Last Working Version

2.1.220

Claude Code Version

2.1.222 (Claude Code); also reproduced with the VS Code extension 2.1.223 and its bundled binary

Platform

Anthropic API

Operating System

Ubuntu/Debian Linux

Terminal/Shell

VS Code integrated terminal

Additional Information

Regression A/B (same directory, same settings, same command):

| Version | Classifier | Result |
|---|---|---|
| 2.1.220 (npx) | outcome=ok | action runs |
| 2.1.222 | 400 "Found 5" | action denied, fail closed |

Two notes that may help triage:

  • CLAUDE_CODE_AUTO_MODE_MODEL appears to be unread in 2.1.22x. I set it in the real process

environment and the classifier still used the same model, so pinning a different classifier
is not available as a workaround.

  • This may be the same underlying problem as #49535 ("auto mode classifier unavailable"),

where the suggested workaround is switching to acceptEdits. Downgrading to 2.1.220 also
restores it.

View original on GitHub ↗

This issue has 2 comments on GitHub. Read the full discussion on GitHub ↗