claude-code - 💡(How to fix) Fix Auto-compact triggers at ~8% context usage (84k/1M), 882k tokens free [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#52981Fetched 2026-04-25 06:15:35
View on GitHub
Comments
2
Participants
3
Timeline
6
Reactions
0
Timeline (top)
labeled ×4commented ×2

Error Message

Error Messages/Logs

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?

<html> <body> <!--StartFragment--><div class="codeBlockWrapper_-a7MRw" style="position: relative; margin: 8px 0px; color: rgb(191, 191, 191); font-family: -apple-system, BlinkMacSystemFont, &quot;Segoe UI&quot;, Roboto, sans-serif; font-size: 13px; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; white-space: normal; background-color: rgb(25, 26, 27); text-decoration-thickness: initial; text-decoration-style: initial; text-decoration-color: initial;"><pre style="overflow-x: auto; white-space: pre; box-sizing: border-box; border-radius: 4px; max-width: 100%; margin: 0px; padding: 8px;"><code class="language-markdown" style="font-family: monospace; color: rgb(140, 140, 140); background-color: rgb(38, 38, 38); padding: 0px; border-radius: 3px; word-break: break-word; font-size: 0.9em;">## Summary Auto-compact is triggering repeatedly (roughly every 1–2 minutes) even though context usage is at ~8% of the available window. Behavior started ~1 day ago; was working fine for months prior.

Environment

  • Claude Code version: 2.1.112
  • Model: claude-opus-4-7[1m] (1M context window)
  • OS: Windows 11 Pro 10.0.26200
  • Shell: bash (Git Bash) / PowerShell available
  • IDE: VS Code native extension

/context output at time of compact

</code></pre></div><p style="white-space: pre-wrap; margin-top: 0.1em; margin-bottom: 0.2em; color: rgb(191, 191, 191); font-family: -apple-system, BlinkMacSystemFont, &quot;Segoe UI&quot;, Roboto, sans-serif; font-size: 13px; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; background-color: rgb(25, 26, 27); text-decoration-thickness: initial; text-decoration-style: initial; text-decoration-color: initial;">Model: claude-opus-4-7[1m] Tokens: 84k / 1m (8%)</p>

CategoryTokens%
System prompt10.3k1.0%
System tools15.8k1.6%
MCP tools (deferred)1.9k0.2%
System tools (deferred)20.4k2.0%
Memory files7.1k0.7%
Skills8890.1%
Messages51k5.1%
Free space881.9k88.2%
Autocompact buffer33k3.3%
<div class="codeBlockWrapper_-a7MRw" style="position: relative; margin: 8px 0px; color: rgb(191, 191, 191); font-family: -apple-system, BlinkMacSystemFont, &quot;Segoe UI&quot;, Roboto, sans-serif; font-size: 13px; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; white-space: normal; background-color: rgb(25, 26, 27); text-decoration-thickness: initial; text-decoration-style: initial; text-decoration-color: initial;"><button class="copyButton_CEmTFw copyButton_-a7MRw" title="Copy code" aria-label="Copy code to clipboard" style="color: rgb(191, 191, 191); font-family: -apple-system, BlinkMacSystemFont, &quot;Segoe UI&quot;, Roboto, sans-serif; font-size: 13px; background: none 0% 0% / auto repeat scroll padding-box border-box rgb(18, 19, 20); border-color: rgb(42, 43, 44); border-style: solid; border-width: 1px; border-image: none 100% / 1 / 0 stretch; cursor: pointer; opacity: 1; display: flex; border-radius: 4px; justify-content: center; align-items: center; padding: 4px; transition: opacity 0.15s, background 0.15s; position: absolute; top: 4px; right: 4px;"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 20" fill="currentColor" aria-hidden="true" data-slot="icon" class="copyIcon_CEmTFw"><path fill-rule="evenodd" d="M15.988 3.012A2.25 2.25 0 0 1 18 5.25v6.5A2.25 2.25 0 0 1 15.75 14H13.5v-3.379a3 3 0 0 0-.879-2.121l-3.12-3.121a3 3 0 0 0-1.402-.791 2.252 2.252 0 0 1 1.913-1.576A2.25 2.25 0 0 1 12.25 1h1.5a2.25 2.25 0 0 1 2.238 2.012ZM11.5 3.25a.75.75 0 0 1 .75-.75h1.5a.75.75 0 0 1 .75.75v.25h-3v-.25Z" clip-rule="evenodd"></path><path d="M3.5 6A1.5 1.5 0 0 0 2 7.5v9A1.5 1.5 0 0 0 3.5 18h7a1.5 1.5 0 0 0 1.5-1.5v-5.879a1.5 1.5 0 0 0-.44-1.06L8.44 6.439A1.5 1.5 0 0 0 7.378 6H3.5Z"></path></svg></button><pre style="overflow-x: auto; white-space: pre; box-sizing: border-box; border-radius: 4px; max-width: 100%; margin: 0px; padding: 8px;"><code style="font-family: monospace; color: rgb(140, 140, 140); background-color: rgb(38, 38, 38); padding: 0px; border-radius: 3px; word-break: break-word; font-size: 0.9em;"> ## Expected behavior With 882k tokens (88%) of free space available, auto-compact should not trigger. Prior to the regression, compaction only fired near the actual context limit.

Actual behavior

Auto-compact fires every ~1–2 minutes regardless of actual usage. Each ### compact event disrupts the working session (re-injects CLAUDE.md files, warms cache, adds latency).

Things I already ruled out

  • Not a model issue — tested with older model, same behavior
  • Not CLAUDE.md size — reduced CLAUDE.md files by 67% (now 7.1k total), problem persists
  • Not memory file size — memory index is ~1.9k, individual entries small

Suspected cause

Regression in auto-compact threshold logic or context-usage calculation in CLI version 2.1.112 (or a recent version). Behavior suggests the threshold is being computed against something other than actual token count, or compaction is being triggered by an unrelated event.

Impact

Severe — makes long-running sessions unusable. Each compact event costs cache invalidation and re-reads of project memory, slowing iteration significantly.</code></pre></div><!--EndFragment-->

</body> </html>

What Should Happen?

Compaction has never happened like this before - it was done 1-2 times a session.

Error Messages/Logs

Steps to Reproduce

Steps to reproduce

  1. Start a normal working session with a moderately-sized project (CLAUDE.md files totaling ~7k tokens, small memory index)
  2. Do ordinary coding work (Read, Grep, Edit on medium-sized files)
  3. Observe: auto-compact fires repeatedly despite /context showing <10% usage

Claude Model

Opus

Is this a regression?

Yes, this worked in a previous version

Last Working Version

?

Claude Code Version

2.1.112

Platform

Anthropic API

Operating System

Windows

Terminal/Shell

VS Code integrated terminal

Additional Information

No response

extent analysis

TL;DR

The issue can be temporarily mitigated by downgrading to a previous version of Claude Code, as the problem seems to be a regression introduced in version 2.1.112.

Guidance

  • Verify that the issue persists when using a different model, to rule out model-specific problems.
  • Check the release notes of previous versions to identify any changes related to auto-compact threshold logic or context-usage calculation.
  • Test the behavior with a minimal project setup to see if the issue is project-specific.
  • Consider reporting the issue to the developers with detailed steps to reproduce, as it seems to be a regression.

Example

No code example is provided, as the issue seems to be related to the Claude Code version rather than a specific code snippet.

Notes

The exact cause of the issue is uncertain, but it appears to be related to a change in the auto-compact threshold logic or context-usage calculation in version 2.1.112.

Recommendation

Apply workaround: Downgrade to a previous version of Claude Code until the issue is fixed, as the problem seems to be a regression introduced in version 2.1.112.

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

With 882k tokens (88%) of free space available, auto-compact should not trigger. Prior to the regression, compaction only fired near the actual context limit.

Still need to ship something?

×6

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

Back to top recommendations

TRENDING