claude-code - 💡(How to fix) Fix [BUG] Compaction fails with "context window limit" error even when context usage is low (e.g., 20%) — regression in v2.1.153

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…

Error Message

Error: Error during compaction: API Error: The model has reached its context window limit.

This error appears both when automatic compaction attempts to run and when manually executing /compact.

Code Example

Error: Error during compaction: API Error: The model has reached its context window limit.

  This error appears both when automatic compaction attempts to run and when manually executing /compact.
RAW_BUFFERClick to expand / collapse

Preflight Checklist

  • 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?

After updating from v2.1.140 to v2.1.153, automatic compaction no longer triggers. Manually running /compact fails with a context window limit error, even though the displayed context usage is only around 20%. This creates an unrecoverable dead-end where the conversation cannot continue and /clear is the only way out, losing all progress.

What Should Happen?

  • Automatic compaction should trigger during extended conversations, as it did in v2.1.140
    • Compaction should succeed when context usage is low (20%)
    • If compaction fails, there should be a fallback mechanism rather than leaving the session unrecoverable

Error Messages/Logs

Error: Error during compaction: API Error: The model has reached its context window limit.

  This error appears both when automatic compaction attempts to run and when manually executing /compact.

Steps to Reproduce

  1. Today I Update Claude Code from v2.1.140 to v2.1.153
  2. Start a conversation and work normally for an extended period
  3. During normal usage, an error suddenly appears: API Error: The model has reached its context window limit.
  4. Observe that automatic compaction never triggered on its own
  5. Notice that context usage remains low (around 20%)
  6. Manually run /compact → fails with the same error
  7. Session is now unrecoverable — only /clear works

Claude Model

Other

Is this a regression?

Yes, this worked in a previous version

Last Working Version

2.1.140

Claude Code Version

2.1.153

Platform

Other

Operating System

macOS

Terminal/Shell

iTerm2

Additional Information

  • This is a regression — compaction worked correctly in v2.1.140
  • No large files were read during the session — context grew through normal conversation and tool usage
  • The error message claims "context window limit" but usage is only ~20%, suggesting hidden context (system prompts, tool definitions, etc.) may be inflating the actual token count beyond what the usage indicator shows
  • Claude Code CLI, macOS (Darwin 25.5.0)

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING