Auto-compact triggers at ~8% context usage (84k/1M), 882k tokens free

Resolved 💬 3 comments Opened Apr 24, 2026 by Alster1964 Closed May 29, 2026

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?

<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>
Category | Tokens | %
-- | -- | --
System prompt | 10.3k | 1.0%
System tools | 15.8k | 1.6%
MCP tools (deferred) | 1.9k | 0.2%
System tools (deferred) | 20.4k | 2.0%
Memory files | 7.1k | 0.7%
Skills | 889 | 0.1%
Messages | 51k | 5.1%
Free space | 881.9k | 88.2%
Autocompact buffer | 33k | 3.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)

  1. Do ordinary coding work (Read, Grep, Edit on medium-sized files)
  2. 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_

View original on GitHub ↗

This issue has 3 comments on GitHub. Read the full discussion on GitHub ↗