[BUG] Context limit reached at ~200K tokens despite 1M context model

Status Fixed / completed
Reported on v2.1.75
Maintainer reply None cached
Activity 4 comments · opened Mar 13, 2026 · closed Mar 15, 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?

Running Claude Code v2.1.75 with Opus 4.6 (1M context) on Claude Max plan. The session hit "Context limit reached · /compact or /clear to continue" at approximately 197K tokens used (20% of advertised 1M context).

Running /context immediately after the limit message confirmed:
claude-opus-4-6[1m] · 197k/1000k tokens (20%)

The model correctly shows [1m] suffix and the denominator is 1,000k, but the practical limit appears to still be enforced around the old 200K boundary.

Environment:

  • Claude Code v2.1.75
  • Model: claude-opus-4-6[1m] (Opus 4.6 with 1M context)
  • Plan: Claude Max
  • Platform: Linux (WSL2) 6.6.87.2-microsoft-standard-WSL2
  • Session type: Long design review conversation with multiple file reads and edits

What Should Happen?

Session should continue until closer to 1M token limit.

Actual behavior: Session stopped at ~197K tokens with "Context limit reached" message, despite 80% of context remaining unused.

Error Messages/Logs

Context limit reached · /compact or /clear to continue                 
                                                                                                                                                 
  /context output at time of error:                                                                                                              
  ⛁ ⛁ ⛁ ⛀ ⛁ ⛁ ⛀ ⛁ ⛁ ⛁ ⛁ ⛁ ⛁ ⛁ ⛁ ⛁ ⛁ ⛁ ⛁ ⛁   claude-opus-4-6[1m] · 197k/1000k tokens (20%)                                                        
                                                                                                                                                 
  Estimated usage by category:                                                                                                                   
  ⛁ System prompt: 5.9k tokens (0.6%)                                                                                                            
  ⛁ System tools: 9.1k tokens (0.9%)                                                                                                             
  ⛁ Custom agents: 956 tokens (0.1%)                                                                                                             
  ⛁ Memory files: 11k tokens (1.1%)                                                                                                              
  ⛁ Skills: 1.2k tokens (0.1%)                                                                                                                   
  ⛁ Messages: 170.3k tokens (17.0%)                                                                                                              
  ⛁ Compact buffer: 3k tokens (0.3%)                                                                                                             
  ⛶ Free space: 799k (79.9%)                                                                                                                     
                                                                                                                                                 
The limit appears to be enforced at the old ~200K boundary despite the model being configured for 1M context. The /context command itself correctly reports the 1M limit (1000k denominator) but the session termination threshold was not updated to match.

Steps to Reproduce

  1. Using Claude Code v2.1.75 with Claude Max plan (Opus 4.6, 1M context)
  2. Start a long conversation involving multiple file reads and edits (design document review session)
  3. Model correctly identifies as claude-opus-4-6[1m] throughout the session
  4. After approximately 197K tokens of conversation, receive "Context limit reached · /compact or /clear to continue"
  5. Run /context immediately after the limit message
  6. Output confirms only 20% of context used: "claude-opus-4-6[1m] · 197k/1000k tokens (20%)"
  7. Session cannot continue despite 800K+ tokens remaining

Claude Model

Opus

Is this a regression?

No, this never worked

Last Working Version

_No response_

Claude Code Version

2.1.75 (Claude Code)

Platform

Anthropic API

Operating System

Ubuntu/Debian Linux

Terminal/Shell

VS Code integrated terminal

Additional Information

_No response_

View original on GitHub ↗

4 Comments

happylivingdigital · 5 months ago

Related to #34143 but distinct — this is not a request for 1M support, it's a bug where 1M context is enabled (model shows [1m], /context shows 1000k denominator) but the session still terminates at ~200K tokens.

johnchandlerburnham · 5 months ago

I had this issue and fixed it:

  1. update Claude Code to latest version
  2. /logout and close all open Claude Code sessions
  3. Delete contents of the s1mAccessCache field from .claude.json:
"s1mAccessCache": {
  "12345678-90ab-cdef-1234-567890abcdef": {
     "hasAccess": false,
     "hasAccessNotAsDefault": false,
     "timestamp": 1771622118644
}

replacing this with "s1mAccessCache": {}

  1. start Claude Code and run /login again

I haven't replicated this, so might not work for others, but I now see Opus 4.6 (1M context) 321562 tokens in my status bar

happylivingdigital · 5 months ago

Resolution: CLAUDE_CODE_BLOCKING_LIMIT_OVERRIDE env var silently capping context at 197K

Symptoms

  • Status bar showed "Opus 4.6 (1M context)"
  • /context showed claude-opus-4-6[1m] · 205k/1000k tokens (20%) with 79% free space
  • Session hit "Context limit reached" at ~197-200K tokens despite displaying 1M capacity
  • Clearing s1mAccessCache in ~/.claude.json did NOT fix the issue

Root Cause

export CLAUDE_CODE_BLOCKING_LIMIT_OVERRIDE=197000 was set in ~/.bashrc — originally added as a workaround for issue #18152 (context window management problems approximately a month prior). At that time, the env var helped stabilize sessions. However, when the 1M context window rolled out, this same env var became the problem — it hard-caps the usable context at the client level, overriding everything else including the 1M window.

All 1M plumbing was working correctly:

  • Model string: claude-opus-4-6[1m] ✓
  • Beta header: context-1m-2025-08-07 included in API requests ✓
  • Feature flag: tengu_cobalt_compass enabled ✓
  • UI display: showing 1M ✓

But CLAUDE_CODE_BLOCKING_LIMIT_OVERRIDE=197000 silently overrode the actual limit, causing Claude Code to trigger "Context limit reached" before the API ever saw a request beyond 197K tokens. The UI gave no indication that an env var was responsible for the discrepancy.

Fix

  1. Commented out the line in ~/.bashrc: # export CLAUDE_CODE_BLOCKING_LIMIT_OVERRIDE=197000
  2. Ran wsl --shutdown from Windows PowerShell (required on WSL2 — closing the terminal alone doesn't clear inherited env vars since the WSL instance persists in background)
  3. Reopened VS Code and started a fresh Claude Code session

Verification

After the fix, successfully loaded 294K tokens (29% of 1M) in a single session with no "Context limit reached" error — well past the previous 197K ceiling. Session remained fully coherent and functional throughout.

Suggestion for the team

This env var creates a confusing UX — the UI reports 1M context but the session dies at the override limit with no indication that an env var is responsible. Anyone who previously set this variable as a workaround (per #18152 or similar) will silently lose access to the 1M context window. Two ideas:

  1. Log a warning at startup when this override is active, e.g.:

⚠️ Context limit overridden to 197K by CLAUDE_CODE_BLOCKING_LIMIT_OVERRIDE (1M available)

  1. Show the effective limit in /context rather than the model's maximum, so the user sees 197k/197k instead of 197k/1000k when an override is active.
github-actions[bot] · 5 months ago

This issue has been automatically locked since it was closed and has not had any activity for 7 days. If you're experiencing a similar issue, please file a new issue and reference this one if it's relevant.