Auto-compact never triggers in CLI sessions (entrypoint: cli) on v2.1.92 with 1M context

Resolved 💬 3 comments Opened Apr 6, 2026 by BGwill-OUTLOOK Closed Apr 10, 2026

Description

Auto-compact does not trigger automatically in CLI sessions (entrypoint: "cli") on v2.1.92 with Opus 4.6 (1M context) on Windows 11. Context reaches 99%+ but compact_boundary events are never emitted. Manual /compact works correctly.

Environment

  • Claude Code version: 2.1.92 (native .exe install)
  • OS: Windows 11 (10.0.26200)
  • Model: claude-opus-4-6 (1M context)
  • Plan: Claude Max
  • Entrypoint: cli (interactive terminal)

Evidence

1. compact_boundary events only fire for sdk-cli entrypoint

Analyzed 164 session JSONL files:

  • 128 sessions with entrypoint: "cli"zero compact_boundary events
  • 36 sessions with entrypoint: "sdk-cli" (from test harness) → compact_boundary fires correctly

Even on the same version (v2.1.87), production CLI sessions never emit compact_boundary, while SDK-CLI test sessions do.

2. Test vs production comparison

Working (test session, sdk-cli, v2.1.87):

{
  "type": "system",
  "subtype": "compact_boundary",
  "content": "Conversation compacted",
  "compactMetadata": { "trigger": "auto", "preTokens": 966342 },
  "entrypoint": "sdk-cli",
  "version": "2.1.87"
}

Not working (production session, cli, v2.1.92):

  • Session d51eb6a7 (3.5MB, 359 assistant turns): zero compact_boundary events
  • Session e586c0da (4.0MB, 552 assistant turns): zero compact_boundary events
  • /tmp/claude_compact_events.log shows zero auto-triggered compaction events since March 29

3. GrowthBook tengu_hawthorn_window mismatch

The GrowthBook-synced feature flag tengu_hawthorn_window is set to 200000 (200K), but the actual model context window is 1M (1,000,000 tokens). This 5x mismatch may cause incorrect threshold calculations.

Modifying ~/.claude.json to fix this value is ineffective — GrowthBook server sync overwrites it back to 200000 on every session startup.

4. Environment variable overrides don't resolve the issue

The following env vars are set in ~/.claude/settings.local.json but auto-compact still doesn't trigger:

{
  "env": {
    "CLAUDE_AUTOCOMPACT_PCT_OVERRIDE": "75",
    "CLAUDE_CODE_AUTO_COMPACT_WINDOW": "900000"
  }
}

5. Manual /compact works

Running /compact manually compresses the conversation successfully and triggers the PostCompact hook. The compression mechanism itself is not broken — only the automatic trigger is affected.

Binary analysis

From the v2.1.92 binary, the auto-compact enable check:

function cZ() {
  if (dH(process.env.DISABLE_COMPACT)) return false;
  if (dH(process.env.DISABLE_AUTO_COMPACT)) return false;
  return z8().autoCompactEnabled;
}

Neither DISABLE_COMPACT nor DISABLE_AUTO_COMPACT are set. autoCompactEnabled defaults to true per official docs.

Steps to reproduce

  1. Start Claude Code v2.1.92 CLI (native .exe) with Opus 4.6 (1M context)
  2. Use the session extensively until context reaches 70%+
  3. Observe that auto-compact never triggers
  4. Run /compact manually — it works
  5. Check JSONL: no compact_boundary subtype events present

Expected behavior

Auto-compact should trigger at ~95% context capacity (or at the CLAUDE_AUTOCOMPACT_PCT_OVERRIDE threshold) regardless of whether the session was started via CLI or SDK-CLI entrypoint.

Workaround

Currently using manual /compact via CLAUDE.md instructions that prompt the AI to proactively call /compact at 70% context.

Related

This may be related to the tengu_hawthorn_window being hardcoded to 200K for 1M context models, causing threshold calculation issues.

View original on GitHub ↗

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