How to stop Claude Code from switching flagged requests to another model
When a safety classifier flags a request (most often cybersecurity or biology content), Claude Code re-runs it on a fallback model automatically. If you don't want the model to change, turn that switch off with an environment variable.
export CLAUDE_CODE_DISABLE_REFUSAL_FALLBACK=1
To keep it off, add it to the env block of settings.json.
{
"env": {
"CLAUDE_CODE_DISABLE_REFUSAL_FALLBACK": "1"
}
}
If you'd rather decide each time, open /config and set Switch models when a message is flagged to Ask each time, or set switchModelsOnFlag to false in settings.json. Claude Code then pauses on each flagged request and asks whether to switch to the fallback model or edit the prompt and retry.
Since 2.1.312 the automatic switch also applies to model names Claude Code doesn't recognize, such as Bedrock deployment names and inference profile ARNs. In those setups, this variable is how you turn it off.
Sources
- Claude Code changelog 2.1.312 (automatic model switches cover unrecognized model names, CLAUDE_CODE_DISABLE_REFUSAL_FALLBACK=1)code.claude.com ↗
- Environment variables – Claude Code Docs (CLAUDE_CODE_DISABLE_REFUSAL_FALLBACK)code.claude.com ↗
- Model configuration – Claude Code Docs (Automatic model fallback, Ask before switching)code.claude.com ↗
Get notified when a new tip lands
Tip alerts only go out in the app. Install it and turn notifications on.