[BUG] 1M context auto-switch triggers at ~72% usage and cannot be disabled via env var
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?
## Summary
Claude Code automatically switches to 1M context mode well before the standard context window is full (observed at
~72% usage). When 1M usage credits are not enabled, this causes a hard error and terminates the session, losing all
context.
## Steps to reproduce
- Start a long working session (code editing, multi-file changes)
- Reach approximately 70–75% of the standard context window
- Claude Code attempts to switch to 1M context mode automatically
- Error: `API Error: Usage credits required for 1M context · run /usage-credits to turn them on, or /model to switch
to standard context`
- Session is terminated — all context is lost
## Expected behavior
Claude Code should either:
- Stay within the standard context window until it is actually full, or
- Provide a working setting to disable the automatic 1M context switch
## Actual behavior
The session crashes at ~72% context usage. The user has to restart and re-explain all context.
## Attempted workaround
Setting CLAUDE_CODE_DISABLE_1M_CONTEXT=1 in ~/.claude/settings.json under env has no effect — the automatic
switch still occurs.
## Environment
- Platform: Windows 11 (win32)
- Shell: PowerShell 5.1
- Claude Code version: latest (claude-sonnet-4-6)
## Impact
Every long session is at risk of abrupt termination without warning. The lost context forces the user to restart from
scratch, which is disruptive and wastes significant time.
What Should Happen?
Claude Code should remain within the standard context window until it is genuinely full. If an automatic upgrade to 1M context is needed, users
should be warned first and given the option to decline (e.g. via auto-compact instead). A working setting to permanently disable the 1M context
auto-switch should be provided — the current CLAUDE_CODE_DISABLE_1M_CONTEXT=1 env var in settings.json has no effect.
Error Messages/Logs
Steps to Reproduce
## Steps to reproduce
- Start a long working session (code editing, multi-file changes)
- Reach approximately 70–75% of the standard context window
- Claude Code attempts to switch to 1M context mode automatically
- Error: `API Error: Usage credits required for 1M context · run /usage-credits to turn them on, or /model to switch
to standard context`
- Session is terminated — all context is lost
Claude Model
None
Is this a regression?
Yes, this worked in a previous version
Last Working Version
_No response_
Claude Code Version
2.1.161 (Claude Code)
Platform
Anthropic API
Operating System
macOS
Terminal/Shell
Terminal.app (macOS)
Additional Information
_No response_
This issue has 2 comments on GitHub. Read the full discussion on GitHub ↗