claude-code - 💡(How to fix) Fix Opus 4.7: auto-compaction at 200k tokens makes it unusable for long sessions [2 comments, 3 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#50888Fetched 2026-04-20 12:10:17
View on GitHub
Comments
2
Participants
3
Timeline
5
Reactions
0
Author
Timeline (top)
labeled ×3commented ×2
RAW_BUFFERClick to expand / collapse

Describe the bug / feedback

Opus 4.7 auto-compacts at around 200k tokens, making it functionally a 200k-context model despite being advertised as 1M context. After compaction, the model spends ~150k tokens reconstructing its context from the compressed summary, only to recompact again almost immediately. In practice this means the model can barely complete a real implementation task before losing the thread.

What makes this worse than Opus 4.6

Opus 4.6 had its own issues but at least accumulated context across the full session. Tasks got done. With 4.7, the constant recompaction means every long session degrades into repeated context-reconstruction cycles. The model behaves like Sonnet 3.5 mid-task — lightweight and forgetful — which defeats the purpose of running the most capable model.

Concrete failure mode (reproducible)

  1. Start a session that requires reading a large codebase (e.g., 180-file project ingest)
  2. The model hits 200k tokens mid-work
  3. Compaction fires. 150k tokens consumed summarizing what just happened
  4. The model has barely recovered when it hits 200k again
  5. Second compaction. The session is now stuck in a loop
  6. Nothing gets built

Expected behavior

Either:

  • (a) the advertised 1M context is actually usable before compaction fires, or
  • (b) compaction fires much later (e.g., 800k), or
  • (c) there's a user-configurable threshold so power users can choose to pay the cache-miss cost and keep a longer context

Suggested fix

Expose a configurable compaction threshold in settings (or ~/.claude/settings.json). The current behavior feels like it optimizes for cost at the expense of capability — which is the opposite of what Opus 4.7 users signed up for.

If the 1M context window is not actually available end-to-end in Claude Code sessions, that should be documented clearly rather than implied.

extent analysis

TL;DR

Exposing a configurable compaction threshold in settings could help mitigate the issue of constant recompaction in Opus 4.7.

Guidance

  • Investigate the feasibility of introducing a user-configurable compaction threshold to allow power users to balance capability and cost.
  • Consider documenting the actual context window available in Claude Code sessions to avoid misleading users about the 1M context capability.
  • Review the compaction logic to determine if it can be optimized to fire less frequently, such as at a higher token threshold (e.g., 800k).
  • Evaluate the impact of the constant recompaction cycles on the model's performance and explore ways to minimize the overhead of context reconstruction.

Example

No code snippet is provided as the issue does not contain specific code references.

Notes

The suggested fix relies on the assumption that introducing a configurable compaction threshold is technically feasible and would effectively address the issue. Further investigation is needed to determine the best approach.

Recommendation

Apply workaround: Expose a configurable compaction threshold in settings to allow users to choose their preferred balance between capability and cost. This approach acknowledges the current limitation and provides a flexible solution until a more permanent fix can be implemented.

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…

FAQ

Expected behavior

Either:

  • (a) the advertised 1M context is actually usable before compaction fires, or
  • (b) compaction fires much later (e.g., 800k), or
  • (c) there's a user-configurable threshold so power users can choose to pay the cache-miss cost and keep a longer context

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 Opus 4.7: auto-compaction at 200k tokens makes it unusable for long sessions [2 comments, 3 participants]