[BUG] Wrong Context Amount and Autocompact

Status Fixed / completed
Maintainer reply ✓ Yes — bcherny
Activity 4 comments · opened Oct 16, 2025 · closed Oct 17, 2025
💡 Likely answer: A maintainer (bcherny, collaborator) responded on this thread — see the highlighted reply below.

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?

After running a short and simple task with the Claude Code Sonnet model, I noticed the message:

Context left until auto-compact: 0%

This made no sense given how small the session was, so I disabled auto-compaction thinking it was a display or logic bug.
Immediately afterward, Claude started showing:

Context low (7% remaining) · Run /compact to compact & continue

However, when I ran /context, it reported accurate values:
34k / 200k tokens (17% usage) — exactly as expected.

So the context usage display in the UI is inconsistent with the real /context output, and Sonnet incorrectly triggers compaction warnings even when there’s plenty of room left.

What Should Happen?

The context usage indicator and auto-compact triggers should reflect the actual token usage reported by /context.
If /context shows only 17% usage, the UI should not warn about 0% or 7% remaining, nor prompt unnecessary manual compaction.
In short, Claude should:

Accurately sync internal context tracking with /context data

Only trigger compaction when the real context buffer is near capacity

Avoid confusing or contradictory warnings when context is clearly sufficient

Error Messages/Logs

Steps to Reproduce

  1. Open a new Claude Code session using the Sonnet model.
  2. Run any short task (for example, a small code generation or edit command).
  3. Observe the message in the output area:
  4. “Context left until auto-compact: 0%”
  5. Disable auto-compact via settings.
  6. Continue the same session or re-run a simple command.
  7. Observe the new warning message:
  8. “Context low (7% remaining) · Run /compact to compact & continue”
  9. Run /context and note the actual usage (around 34k / 200k tokens, ~17%).

Claude Model

Sonnet (default)

Is this a regression?

Yes, this worked in a previous version

Last Working Version

2.0.18

Claude Code Version

2.0.19

Platform

Anthropic API

Operating System

Other Linux

Terminal/Shell

Other

Additional Information

<img width="579" height="558" alt="Image" src="https://github.com/user-attachments/assets/aa4bffe8-3867-47b5-bc0a-d7b5a17cc780" />

<img width="583" height="603" alt="Image" src="https://github.com/user-attachments/assets/085b1b1b-a30e-4073-8655-32db2efbb8f5" />

View original on GitHub ↗

4 Comments

github-actions[bot] · 1 year ago

Found 2 possible duplicate issues:

  1. https://github.com/anthropics/claude-code/issues/9353
  2. https://github.com/anthropics/claude-code/issues/9517

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

bcherny collaborator · 12 months ago

Fix landed, and is going out tomorrow morning. Thanks for the report!

bradenriggins · 12 months ago

@bcherny Fix landed! And yet it's still happening.

github-actions[bot] · 11 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.