You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[BUG] Turning auto-compact OFF won't allow to continue until you fill the 200K tokens window anymore (it worked before). #18152
I have searched existing issues and this hasn't been reported yet
This is a single bug report (please file separate reports for different bugs)
I am using the latest version of Claude Code
What's Wrong?
[BUG] Turning auto-compact OFF won't allow to continue until you fill the 200K tokens window anymore (it worked before).
What Should Happen?
You should continue conversation until you fill the 200K tokens window, not when you reach the recommended limit to run /compact! It used to work prior to 2.1.7 maybe even < 2.1.5
Error Messages/Logs
Steps to Reproduce
Just keep clauding until you reach the 0% remaining threshold and check the context.
Claude Model
Opus
Is this a regression?
Yes, this worked in a previous version
Last Working Version
No response
Claude Code Version
2.1.7
Platform
Anthropic API
Operating System
Ubuntu/Debian Linux
Terminal/Shell
WSL (Windows Subsystem for Linux)
Additional Information
Reacted by Maurice, I. Dedova, michelsdev, Ryan Atkinson, Keith Harper, psychcook, thielm, Damir Murat, Daniel Kouznetsov, Pablo Gutierrez and 9 more
(Note: The following was entirely prepared by Claude Code, and my input was minimal. Please take it with a grain of extra salt. It took me a few sessions to somehow replicate the problems and let Claude Code inspect the logs though.)
(Note 2: I saw this ("Fixed context window blocking limit being calculated using the full context window instead of the effective context window (which reserves space for max output tokens") in the latest change of 2.1.7 and had Claude Code dig deeper and thus got these.)
Possible Root Cause: v2.1.7 Blocking Limit Change
After experiencing premature "Prompt is too long" errors, a source code diff between v2.1.6 and v2.1.7 revealed a change in how the blocking limit is calculated that may explain the reduced effective context window.
Problem
Sessions appear to hit "Prompt is too long" at ~130K tokens instead of ~197K tokens. The client-side blocking limit validation seems to reject prompts before they reach the API, even when there may be context remaining.
Source Location
The blocking limit logic is in the bundled CLI:
node_modules/@anthropic-ai/claude-code/cli.js
Since it's minified, search for isAtBlockingLimit: to find the relevant function.
Returns max output tokens for model (64K for Opus 4.5)
mL0
constant
Buffer before blocking, value: 3000
The Change
v2.1.6 (function kp near byte offset 9,913,000):
functionkp(A){// ...W=x8(),// get model nameK=p$(W,_w())-pR0,// BLOCKING = contextWindow - 3000V=process.env.CLAUDE_CODE_BLOCKING_LIMIT_OVERRIDE,F=V?parseInt(V,10):NaN,H=!isNaN(F)&&F>0?F:K,// use override if set, else KE=A>=H;// isAtBlockingLimitreturn{...isAtBlockingLimit:E}}
v2.1.7 (function ic near byte offset 9,384,000):
functionic(A){// ...D=q3A()-mL0,// BLOCKING = effectiveContext - 3000W=process.env.CLAUDE_CODE_BLOCKING_LIMIT_OVERRIDE,K=W?parseInt(W,10):NaN,V=!isNaN(K)&&K>0?K:D,// use override if set, else DF=A>=V;// isAtBlockingLimitreturn{...isAtBlockingLimit:F}}
v2.1.7 q3A() definition:
functionq3A(){letA=B5(),// model nameQ=dL0(A);// maxOutputTokens (64000 for opus-4-5)returnJq(A,SM())-Q// contextWindow - maxOutputTokens}
Observed Impact
The blocking limit formula appears to have changed from using raw contextWindow to using q3A() (effective context), which already subtracts maxOutputTokens:
Version
Formula
Opus 4.5 Blocking Limit
v2.1.6
contextWindow - 3000
~197,000
v2.1.7
(contextWindow - maxOutputTokens) - 3000
~133,000
This appears to result in ~64K fewer usable tokens for Opus 4.5 and Sonnet 4 (which both have 64K max output).
Workaround
Both versions check for CLAUDE_CODE_BLOCKING_LIMIT_OVERRIDE before using the calculated value:
// v2.1.7:
W=process.env.CLAUDE_CODE_BLOCKING_LIMIT_OVERRIDE,
K=W?parseInt(W,10):NaN,
V=!isNaN(K)&&K>0?K:D, // use override K if valid, otherwise use calculated D
F=A>=V; // isAtBlockingLimit
Setting this env var and restarting Claude Code may restore v2.1.6 behavior:
export CLAUDE_CODE_BLOCKING_LIMIT_OVERRIDE=197000
claude # restart for it to take effect
Reacted by Ryan Atkinson, strjob, happylivingdigital, Vik Develops, Dave West, Pablo Gutierrez, Andre Machon, Miguel Rojas and vlwkaos
Reacted by Alessandro Avenali, I. Dedova, happylivingdigital, Cenk KIRAN, Vik Develops, Dave West, Pablo Gutierrez and Miguel Rojas
+1 - This is blocking upgrades past 2.1.6 for users who rely on manual context management.
Use case: When autoCompact is disabled, users expect full control over when compaction happens. The v2.1.7 change forces early blocking at ~65-80% regardless of this setting, which defeats the purpose of disabling auto-compact.
Suggested fix: Only apply the output token reservation when autoCompact is enabled. Users who disable it have explicitly opted into manual management and accept the risk of hitting the true limit.
Thanks for the workaround CLAUDE_CODE_BLOCKING_LIMIT_OVERRIDE=197000 - using that for now, but would prefer a proper fix or setting.
Reacted by Vincent Tsz-Fai Chow, strjob, happylivingdigital, Daniel Kouznetsov, Pablo Gutierrez, Cenk KIRAN, pgaufillet, Andre Machon, Miguel Rojas, Ben Randall and 5 more
Still reproducing on v2.1.42 with Claude Opus 4.6 — and now even worse.
Environment
Claude Code: v2.1.42
Model: claude-opus-4-6
OS: macOS Darwin 24.5.0
autoCompact: false in settings
CLAUDE_CODE_BLOCKING_LIMIT_OVERRIDE=197000 set in environment
Observed Behavior
Auto-compaction triggers at approximately 150k tokens (~75% of 200k window), despite:
autoCompact: false explicitly configured
CLAUDE_CODE_BLOCKING_LIMIT_OVERRIDE=197000 set (the community workaround from this thread)
The /context command reports against the full 200k window, showing ~67% free space — but compaction fires anyway. This is a regression from the 160-170k limit reported in earlier comments on this issue.
Key Observation: BLOCKING_LIMIT_OVERRIDE Does Not Prevent Auto-Compaction
The CLAUDE_CODE_BLOCKING_LIMIT_OVERRIDE env var appears to only control the blocking limit (when CC refuses to send new prompts), not the auto-compaction trigger threshold. These appear to be separate code paths. Even with the override set to 197000, auto-compaction fires at ~150k.
This means the community workaround only partially addresses the issue — it prevents premature blocking but not premature compaction.
Impact
For complex codebases with large CLAUDE.md files and hook infrastructure, the effective usable context is approximately 80-85k tokens of actual conversation (after ~65k of system prompt, tools, and memory files). Auto-compacting at 150k total means we get roughly half the expected working context before catastrophic 93% context loss.
This makes sustained work on complex projects extremely difficult — context compaction destroys working state every 15-20 tool calls, requiring expensive recovery protocols.
Request
Fix the auto-compaction trigger to respect autoCompact: false
Ensure CLAUDE_CODE_BLOCKING_LIMIT_OVERRIDE (or a new env var) controls the compaction threshold too
For Opus 4.6 with 128k maxOutputTokens, the formula (contextWindow - maxOutputTokens) - 3000 yields only ~69k effective context — this is catastrophically low
Previously filed as #24856 (auto-duped to this issue).
Using CLAUDE_CODE_BLOCKING_LIMIT_OVERRIDE for a while seemed to help. Today, in two separate terminals, I have 2.1.51 and 2.1.56 returning Context limit reached · /compact or /clear to continue at around 175k token usage.
I have auto compact turned off in the /config as I want to manage this myself.
Please do let me know if I can assist by providing any information to help debug this issue.
I just hit this again today. Including the buffer, I am at 90% used. I usually run to the full 98%. The statusline count says 177413.
/context shows plenty of free space
⎿ Context Usage
⛁ ⛁ ⛁ ⛁ ⛁ ⛀ ⛁ ⛁ ⛀ ⛁ claude-opus-4-5 · 177k/200k tokens (88%)
⛀ ⛁ ⛁ ⛁ ⛁ ⛁ ⛁ ⛁ ⛁ ⛁
⛁ ⛁ ⛁ ⛁ ⛁ ⛁ ⛁ ⛁ ⛁ ⛁ Estimated usage by category
⛁ ⛁ ⛁ ⛁ ⛁ ⛁ ⛁ ⛁ ⛁ ⛁ ⛁ System prompt: 3.7k tokens (1.9%)
⛁ ⛁ ⛁ ⛁ ⛁ ⛁ ⛁ ⛁ ⛁ ⛁ ⛁ System tools: 7.2k tokens (3.6%)
⛁ ⛁ ⛁ ⛁ ⛁ ⛁ ⛁ ⛁ ⛁ ⛁ ⛁ MCP tools: 3.7k tokens (1.9%)
⛁ ⛁ ⛁ ⛁ ⛁ ⛁ ⛁ ⛁ ⛁ ⛁ ⛁ Custom agents: 46 tokens (0.0%)
⛁ ⛁ ⛁ ⛁ ⛁ ⛁ ⛁ ⛁ ⛁ ⛁ ⛁ Memory files: 1.5k tokens (0.7%)
⛁ ⛁ ⛁ ⛁ ⛁ ⛁ ⛁ ⛁ ⛁ ⛁ ⛁ Skills: 519 tokens (0.3%)
⛁ ⛀ ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛁ ⛀ ⛁ Messages: 161.2k tokens (80.6%)
⛁ Compact buffer: 3k tokens (1.5%)
⛶ Free space: 19k (9.6%)
... (removed)
Suggestions
⚠ Context is 88% full
Autocompact is disabled. Use /compact to free space, or enable autocompact in
/config.
ℹ Read results using 50k tokens (25%) → save ~15k
Use offset and limit parameters to read only the sections you need. Avoid
re-reading entire files when you only need a few lines.
Even more interesting is that after an exit and resume it seems to have auto-compacted some file reads in the background and recovered a huge chunk of context space, but I still can't continue. At this point, the top line 88% free is overstated. This is interesting but not 100% relevant because even before this I should have been allowed to continue.
⎿ Context Usage
⛁ ⛁ ⛁ ⛁ ⛁ ⛀ ⛁ ⛁ ⛀ ⛁ claude-opus-4-5 · 177k/200k tokens (88%)
⛀ ⛁ ⛁ ⛁ ⛁ ⛁ ⛁ ⛁ ⛁ ⛁
⛁ ⛁ ⛁ ⛁ ⛁ ⛁ ⛁ ⛁ ⛁ ⛁ Estimated usage by category
⛁ ⛁ ⛁ ⛁ ⛁ ⛁ ⛁ ⛁ ⛁ ⛁ ⛁ System prompt: 3.9k tokens (1.9%)
⛁ ⛁ ⛁ ⛁ ⛁ ⛁ ⛁ ⛁ ⛁ ⛁ ⛁ System tools: 7.2k tokens (3.6%)
⛁ ⛁ ⛁ ⛁ ⛁ ⛁ ⛁ ⛁ ⛁ ⛁ ⛁ MCP tools: 3.7k tokens (1.9%)
⛁ ⛁ ⛁ ⛁ ⛁ ⛁ ⛁ ⛁ ⛁ ⛁ ⛁ Custom agents: 46 tokens (0.0%)
⛁ ⛁ ⛁ ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛁ Memory files: 1.5k tokens (0.7%)
⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛁ Skills: 519 tokens (0.3%)
⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛁ ⛀ ⛁ Messages: 124k tokens (62.0%)
⛁ Compact buffer: 3k tokens (1.5%)
⛶ Free space: 56k (28.1%)
... (removed)
Suggestions
⚠ Context is 88% full
Autocompact is disabled. Use /compact to free space, or enable autocompact in
/config.
ℹ Read results using 40.4k tokens (20%) → save ~12.1k
Use offset and limit parameters to read only the sections you need. Avoid
re-reading entire files when you only need a few lines.
You may have noticed I use opus 4.5. I have access to opus 4.6 with 1m token window, but it is inferior and I prefer opus 4.5 with a 198k context window. I do really need that last 20k though.
I'm hitting this as well. Super frustrating as it stopped in the middle of outputting a bunch of code changes when clearly there was enough space to do so.
Please can we get a dev to acknowledge this issue? I know you're vibecoding every new update now but this has been occurring for months and means we're literally not getting the full context we're paying for.
I commented on another thread how to troubleshoot it, if you implemented CLAUDE_CODE_BLOCKING_LIMIT_OVERRIDE, there's nothing Anthropic can do about it. It is your custom settings that is forcing the problem and not letting you access the 1m. You need to remove it on your machine, and it will work. #34958 (comment)
If you are on the Max plan, your Opus 4.6 has 1m context by default. And it will not render if you have that blocking limit in place.
reproducable easily in 2.1.117
I have this all the time with Max plan and Sonnet
this usually happens when there is 11/12/13% context remaining until the 200k
pretty odd since we can no longer use Opus 4.6 or just be able to use Sonnet 4.6 1M :/
Sonnet 4.6 is in many situations useless or hard to work with in many workflows
Does anyone else with this issue use a custom system prompt or disable built-in tools like I do? I was just wondering if the difference is actually the difference between the standard system prompt and tool schemas and what I actually have, which could be the 30k tokens difference.
For folks who turn auto-compact off specifically to avoid losing context, an offline prune is a good middle path: it reclaims space by stubbing old tool results and dropping superseded file reads, without the summarization that compaction does. We built cozempic for this — cozempic treat <session-id> --execute (install via uvx cozempic) shrinks the transcript so you can resume with real headroom (it writes a backup first), and a guard daemon can auto-prune at thresholds you set instead of relying on CC's compaction trigger. Doesn't fix the regression in the blocking-limit calc, but it unblocks the session.
Hitting this as well lately. Very frustrating to disable auto compact and get none of the pros but all of the cons. Something is not working correctly here
Activity
i-dedova commentedon Jan 14, 2026
Exactly! This thing showed up yesterday and was working fine before! It now doesn't allow to continue on 170+k!
tfvchow commentedon Jan 14, 2026
(Note: The following was entirely prepared by Claude Code, and my input was minimal. Please take it with a grain of extra salt. It took me a few sessions to somehow replicate the problems and let Claude Code inspect the logs though.)
(Note 2: I saw this ("Fixed context window blocking limit being calculated using the full context window instead of the effective context window (which reserves space for max output tokens") in the latest change of 2.1.7 and had Claude Code dig deeper and thus got these.)
Possible Root Cause: v2.1.7 Blocking Limit Change
After experiencing premature "Prompt is too long" errors, a source code diff between v2.1.6 and v2.1.7 revealed a change in how the blocking limit is calculated that may explain the reduced effective context window.
Problem
Sessions appear to hit "Prompt is too long" at ~130K tokens instead of ~197K tokens. The client-side blocking limit validation seems to reject prompts before they reach the API, even when there may be context remaining.
Source Location
The blocking limit logic is in the bundled CLI:
node_modules/@anthropic-ai/claude-code/cli.js
Since it's minified, search for
isAtBlockingLimit:to find the relevant function.Key Functions and Constants
v2.1.6:
kp(A){isAtBlockingLimit, ...}p$(W, _w())x8()pR03000v2.1.7:
ic(A){isAtBlockingLimit, ...}q3A()contextWindow - maxOutputTokensJq(A, SM())dL0(A)mL03000The Change
v2.1.6 (function
kpnear byte offset 9,913,000):v2.1.7 (function ic near byte offset 9,384,000):
v2.1.7 q3A() definition:
Observed Impact
The blocking limit formula appears to have changed from using raw contextWindow to using q3A() (effective context), which already subtracts maxOutputTokens:
contextWindow - 3000(contextWindow - maxOutputTokens) - 3000This appears to result in ~64K fewer usable tokens for Opus 4.5 and Sonnet 4 (which both have 64K max output).
Workaround
Both versions check for CLAUDE_CODE_BLOCKING_LIMIT_OVERRIDE before using the calculated value:
Setting this env var and restarting Claude Code may restore v2.1.6 behavior:
thielm commentedon Jan 15, 2026
+1 - This is blocking upgrades past 2.1.6 for users who rely on manual context management.
Use case: When
autoCompactis disabled, users expect full control over when compaction happens. The v2.1.7 change forces early blocking at ~65-80% regardless of this setting, which defeats the purpose of disabling auto-compact.Suggested fix: Only apply the output token reservation when
autoCompactis enabled. Users who disable it have explicitly opted into manual management and accept the risk of hitting the true limit.Thanks for the workaround
CLAUDE_CODE_BLOCKING_LIMIT_OVERRIDE=197000- using that for now, but would prefer a proper fix or setting.cversek commentedon Feb 14, 2026
Still reproducing on v2.1.42 with Claude Opus 4.6 — and now even worse.
Environment
autoCompact: falsein settingsCLAUDE_CODE_BLOCKING_LIMIT_OVERRIDE=197000set in environmentObserved Behavior
Auto-compaction triggers at approximately 150k tokens (~75% of 200k window), despite:
autoCompact: falseexplicitly configuredCLAUDE_CODE_BLOCKING_LIMIT_OVERRIDE=197000set (the community workaround from this thread)The
/contextcommand reports against the full 200k window, showing ~67% free space — but compaction fires anyway. This is a regression from the 160-170k limit reported in earlier comments on this issue.Key Observation: BLOCKING_LIMIT_OVERRIDE Does Not Prevent Auto-Compaction
The
CLAUDE_CODE_BLOCKING_LIMIT_OVERRIDEenv var appears to only control the blocking limit (when CC refuses to send new prompts), not the auto-compaction trigger threshold. These appear to be separate code paths. Even with the override set to 197000, auto-compaction fires at ~150k.This means the community workaround only partially addresses the issue — it prevents premature blocking but not premature compaction.
Impact
For complex codebases with large CLAUDE.md files and hook infrastructure, the effective usable context is approximately 80-85k tokens of actual conversation (after ~65k of system prompt, tools, and memory files). Auto-compacting at 150k total means we get roughly half the expected working context before catastrophic 93% context loss.
This makes sustained work on complex projects extremely difficult — context compaction destroys working state every 15-20 tool calls, requiring expensive recovery protocols.
Request
autoCompact: falseCLAUDE_CODE_BLOCKING_LIMIT_OVERRIDE(or a new env var) controls the compaction threshold toomaxOutputTokens, the formula(contextWindow - maxOutputTokens) - 3000yields only ~69k effective context — this is catastrophically lowPreviously filed as #24856 (auto-duped to this issue).
brandall76 commentedon Feb 25, 2026
Using
CLAUDE_CODE_BLOCKING_LIMIT_OVERRIDEfor a while seemed to help. Today, in two separate terminals, I have 2.1.51 and 2.1.56 returningContext limit reached · /compact or /clear to continueat around 175k token usage.I have auto compact turned off in the /config as I want to manage this myself.
Please do let me know if I can assist by providing any information to help debug this issue.
i-dedova commentedon Feb 25, 2026
agree same issue, I too am back to context limit reached at 179k... quite annoying
cseickel commentedon Mar 16, 2026
I just hit this again today. Including the buffer, I am at 90% used. I usually run to the full 98%. The statusline count says 177413.
/context shows plenty of free space
Even more interesting is that after an exit and resume it seems to have auto-compacted some file reads in the background and recovered a huge chunk of context space, but I still can't continue. At this point, the top line 88% free is overstated. This is interesting but not 100% relevant because even before this I should have been allowed to continue.
You may have noticed I use opus 4.5. I have access to opus 4.6 with 1m token window, but it is inferior and I prefer opus 4.5 with a 198k context window. I do really need that last 20k though.
tacertain commentedon Mar 22, 2026
I'm hitting this as well. Super frustrating as it stopped in the middle of outputting a bunch of code changes when clearly there was enough space to do so.
PS. I have no idea why it reports my model as opus[1m]. I'm using the normal opus.
hi-fox commentedon Mar 26, 2026
Confirmed still occurring on 2.1.84:
Please can we get a dev to acknowledge this issue? I know you're vibecoding every new update now but this has been occurring for months and means we're literally not getting the full context we're paying for.
i-dedova commentedon Mar 26, 2026
I commented on another thread how to troubleshoot it, if you implemented CLAUDE_CODE_BLOCKING_LIMIT_OVERRIDE, there's nothing Anthropic can do about it. It is your custom settings that is forcing the problem and not letting you access the 1m. You need to remove it on your machine, and it will work.
#34958 (comment)
If you are on the Max plan, your Opus 4.6 has 1m context by default. And it will not render if you have that blocking limit in place.
vlwkaos commentedon Apr 10, 2026
loonylabs commentedon Apr 23, 2026
reproducable easily in 2.1.117
I have this all the time with Max plan and Sonnet
this usually happens when there is 11/12/13% context remaining until the 200k
pretty odd since we can no longer use Opus 4.6 or just be able to use Sonnet 4.6 1M :/
Sonnet 4.6 is in many situations useless or hard to work with in many workflows
cseickel commentedon Apr 23, 2026
Does anyone else with this issue use a custom system prompt or disable built-in tools like I do? I was just wondering if the difference is actually the difference between the standard system prompt and tool schemas and what I actually have, which could be the 30k tokens difference.
junaidtitan commentedon May 21, 2026
For folks who turn auto-compact off specifically to avoid losing context, an offline prune is a good middle path: it reclaims space by stubbing old tool results and dropping superseded file reads, without the summarization that compaction does. We built cozempic for this —
cozempic treat <session-id> --execute(install viauvx cozempic) shrinks the transcript so you can resume with real headroom (it writes a backup first), and a guard daemon can auto-prune at thresholds you set instead of relying on CC's compaction trigger. Doesn't fix the regression in the blocking-limit calc, but it unblocks the session.J-Swift commentedon Jul 13, 2026
Hitting this as well lately. Very frustrating to disable auto compact and get none of the pros but all of the cons. Something is not working correctly here