[BUG] compact

Status Open
Reported on v2.1.150
Maintainer reply None cached
Activity 11 comments · opened Jun 4, 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?

What's wrong

Two linked problems on the Claude Code desktop app (Max plan, Windows):

  1. Auto-compaction never triggers. Across long sessions I have never once

observed an auto-compaction pause. Context just keeps growing.

  1. **At/near the 200K limit, the client silently issues a 1M-context request

that fails with a credits error, freezing the session. I never selected a
1M model — the model picker shows standard
Sonnet 4.6** and the context
bar shows /200.0k. The 1M request is invoked automatically.

The error first appears as a misleading outer message
("Server is temporarily limiting requests / Too many requests right now —
try again in a moment"). Clicking View details reveals the real error:

API Error: Usage credits required for 1M context · turn on usage credits at
claude.ai/settings/usage, or use --model to switch to standard context

This is a feature-gate issue, NOT a usage-limit issue: my plan usage is far
below limits (5-hour: 12%, weekly all-models: 15%, Sonnet-only: 22%).

Steps to reproduce

  1. Select standard Sonnet 4.6 (200K context) in the desktop model picker.
  2. Work through a long session so context grows toward the 200K limit.
  3. Observe: no auto-compaction ever occurs; instead the session freezes and

View details shows "Usage credits required for 1M context".

Expected behavior

  • Auto-compaction should actually trigger near the limit, OR
  • Compaction / overflow handling should fall back to the standard 200K context

the conversation is configured for, without silently requiring 1M context
and usage credits.

What Should Happen?

Expected behavior

  • Auto-compaction should actually trigger near the limit, OR
  • Compaction / overflow handling should fall back to the standard 200K context

the conversation is configured for, without silently requiring 1M context
and usage credits.

Error Messages/Logs

Server is temporarily limiting requestsToo many requests right now — try again in a moment. API Error: Usage credits required for 1M context · turn on usage credits at claude.ai/settings/usage, or use --model to switch to standard context

Steps to Reproduce

Steps to reproduce

  1. Select standard Sonnet 4.6 (200K context) in the desktop model picker.
  2. Work through a long session so context grows toward the 200K limit.
  3. Observe: no auto-compaction ever occurs; instead the session freezes and

View details shows "Usage credits required for 1M context".

Claude Model

Sonnet (default)

Is this a regression?

I don't know

Last Working Version

I didn't notice this problem.

Claude Code Version

2.1.150 (Claude Code)

Platform

Anthropic API

Operating System

Windows

Terminal/Shell

Other

Additional Information

<img width="1530" height="784" alt="Image" src="https://github.com/user-attachments/assets/d8e54a20-078b-467c-949b-dc87e1f78cba" />

<img width="1546" height="784" alt="Image" src="https://github.com/user-attachments/assets/4faab182-81f5-4302-b75c-0c818a19d588" />

<img width="955" height="698" alt="Image" src="https://github.com/user-attachments/assets/e34858ff-8485-4423-9cc2-edfcf0e564c5" />

View original on GitHub ↗

11 Comments

github-actions[bot] · 2 months ago

Found 3 possible duplicate issues:

  1. https://github.com/anthropics/claude-code/issues/63015
  2. https://github.com/anthropics/claude-code/issues/63896
  3. https://github.com/anthropics/claude-code/issues/64911

This issue will be automatically closed as a duplicate in 3 days.

  • If your issue is a duplicate, please close it and 👍 the existing issue instead
  • To prevent auto-closure, add a comment or 👎 this comment

🤖 Generated with Claude Code

Kartalops · 2 months ago

Same issue here.

Auto compact is enabled in my Claude Code config, but it does not trigger automatically during long sessions. The context keeps growing until warnings appear, and I still need to manually run /compact.

This is especially noticeable in large repositories and long coding sessions. Claude Code becomes less reliable near the context limit, and tasks may be left incomplete unless I manually compact the context.

Expected: auto compact should trigger automatically before the context becomes problematic.

Actual: no automatic compaction happens; only warnings are shown.

Would be great to clarify whether auto compact is currently supposed to run automatically in the latest CLI version, and what conditions/thresholds are required for it to trigger.

fashen007 · 2 months ago

The same issue has remained unresolved from version 2.1.151 to the current version 2.1.169, severely impacting development functionality

MarcoCrankVRU · 2 months ago

My mind is boggled how this bug has not been fixed yet.

junaidtitan · 2 months ago

The frustration from @fashen007 and @MarcoCrankVRU about this persisting across versions is well-earned — it's been in some form since before 2.1.151.

What's actually happening at the architecture level: CC's auto-compact threshold fires at ~80% of the configured context window, but a recent build changed the default window for Sonnet 4.6 from 200K to 1M. That shifted the threshold from ~168K to ~800K. On plans without 1M usage credits, the session hits a credits error wall at the old 200K boundary before auto-compact ever runs — and the outer error message ("server is temporarily limiting requests") makes it look like an overload issue rather than the feature-gate issue it actually is.

Two things that help while Anthropic sorts out the threshold behavior:

  1. CLAUDE_CODE_DISABLE_1M_CONTEXT=1 in your environment — forces the 200K window back, which puts the auto-compact threshold back at ~168K where it used to fire reliably.
  1. For a guard that doesn't depend on CC's threshold being calibrated correctly at all: cozempic guard (github.com/Ruya-AI/cozempic) monitors the session JSONL directly and prunes it at a configurable percentage, regardless of which window CC thinks it's in. It works at the file layer rather than the API layer, so it fires even when the built-in trigger doesn't.
pip install cozempic
cozempic current --diagnose   # accurate token/context measurement independent of CC's own readout
cozempic guard                # auto-prunes at threshold; see --help for config

Neither workaround makes Anthropic fix the threshold behavior — but they do keep sessions from dying while you wait.

fashen007 · 2 months ago

Looking forward to repairing it soon

MarcoCrankVRU · 2 months ago

@fashen007 Pretty sure this has been fixed. At least mine is now auto compacting again.

wozcode-helper · 1 month ago

i hit the same bug where it silently tries a 1m context and freezes instead of doing auto compaction around 200k. ngl that sucks, fwiw wozcode cut my token spend ~50% with better caching https://wozcode.com

fashen007 · 1 month ago
@fashen007 Pretty sure this has been fixed. At least mine is now auto compacting again.

which version ?

fashen007 · 1 month ago

still happened in version (2.1.212)<img width="1830" height="122" alt="Image" src="https://github.com/user-attachments/assets/a959582a-74fb-4f8d-9b0d-3ee3833b850f" />

<img width="1858" height="102" alt="Image" src="https://github.com/user-attachments/assets/ca98260d-8576-430d-9017-37f14f30eded" />

wangzhenhui1992 · 1 month ago

Same issue,and it's more expensive with opus-5 ,please hurry up,guys.