claude-code - 💡(How to fix) Fix [BUG] Auto-compact fails when 200K standard context is exhausted — compaction API requires extended context [1 comments, 2 participants]

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…
GitHub stats
anthropics/claude-code#48893Fetched 2026-04-16 06:48:06
View on GitHub
Comments
1
Participants
2
Timeline
6
Reactions
0
Timeline (top)
labeled ×4commented ×1cross-referenced ×1

Error Message

Error: Error during compaction: API Error: Extra usage is required for 1M context

Error Messages/Logs

Fix Action

Fix / Workaround

  1. Start session with auto-compact enabled on standard 200K Sonnet
  2. Run a long session (audit, many tool calls, agent dispatches)
  3. Context hits 100% — auto-compact never fires
  4. /compact → "Extra usage required for 1M context"
  5. Workaround: /model → Opus 1M → /compact succeeds
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?

When auto-compact is enabled and the standard 200K context window fills up, /compact fails with:

Error: Error during compaction: API Error: Extra usage is required for 1M context

Auto-compact never fires proactively. The session reaches 100% usage without compaction. The user must manually switch to a 1M model before compaction succeeds.

Additional Context:

PostToolUse hook payloads do not include context_window data. The statusline receives it, but hooks don't — this may explain why auto-compact can't detect the threshold.

Related: #23432, #25695, #29330, #34296

What Should Happen?

Auto-compact should fire before the window is fully exhausted, or the compaction API should work within 200K.

Error Messages/Logs

Steps to Reproduce

  1. Start session with auto-compact enabled on standard 200K Sonnet
  2. Run a long session (audit, many tool calls, agent dispatches)
  3. Context hits 100% — auto-compact never fires
  4. /compact → "Extra usage required for 1M context"
  5. Workaround: /model → Opus 1M → /compact succeeds

Claude Model

Sonnet (default)

Is this a regression?

Yes, this worked in a previous version

Last Working Version

No response

Claude Code Version

2.1.110

Platform

Anthropic API

Operating System

Other Linux

Terminal/Shell

Other

Additional Information

No response

extent analysis

TL;DR

The auto-compact feature fails to trigger before the 200K context window is fully exhausted, requiring manual model switching to 1M for successful compaction.

Guidance

  • The issue seems to be related to the missing context_window data in PostToolUse hook payloads, which might prevent auto-compact from detecting the threshold.
  • Verify that the context_window data is being sent correctly to the statusline, but not to the hooks, by checking the payload contents.
  • Investigate the related issues (#23432, #25695, #29330, #34296) to see if they provide any insights into the problem or potential solutions.
  • Consider modifying the auto-compact logic to use an alternative method for detecting the context window threshold, if the hook payload issue cannot be resolved.

Example

No code example is provided due to the lack of specific implementation details in the issue.

Notes

The issue is reported as a regression, indicating that it worked in a previous version, but the last working version is not specified. This information might be crucial in identifying the root cause.

Recommendation

Apply workaround: manually switch to a 1M model before compaction, as described in the steps to reproduce, until a proper fix is available. This is because the current auto-compact feature is not functioning as expected, and manual intervention is required to successfully compact the context window.

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

claude-code - 💡(How to fix) Fix [BUG] Auto-compact fails when 200K standard context is exhausted — compaction API requires extended context [1 comments, 2 participants]