[BUG] CLAUDE_AUTOCOMPACT_PCT_OVERRIDE=50 does not trigger autocompact — context reaches 100% requiring manual /compact

Open 💬 11 comments Opened Apr 23, 2026 by taku-me

Bug

CLAUDE_AUTOCOMPACT_PCT_OVERRIDE set to 50 in settings.json does not trigger automatic compaction. The context window reaches 100% and Claude Code shows the hard limit prompt (Context limit reached · /compact or /clear to continue), requiring manual /compact every time.

Version

Claude Code v2.1.118, Sonnet 4.6 (200k context), macOS Darwin 25.4.0

Reproduction

Settings (~/.claude/settings.json)

{
  "env": {
    "CLAUDE_AUTOCOMPACT_PCT_OVERRIDE": "50"
  }
}

Steps

  1. Start a Claude Code session with the above setting
  2. Run a moderately long session with multi-agent tasks and file reads (e.g., 5–10 subagent spawns)
  3. Observe that autocompact never fires at 50% — context grows to 100%
  4. Claude Code shows: Context limit reached · /compact or /clear to continue
  5. Must manually type /compact to continue

Expected behavior

Autocompact should trigger when context usage reaches 50%, preventing the hard limit.

Actual behavior

Autocompact never fires. Context reaches 100% regardless of the configured threshold.

Notes

  • Related to #42394 (same env var unreliable, but that report is about firing too early; this is the opposite: never fires)
  • The PreCompact hook (~/.claude/hooks/pre-compact.sh) runs correctly when manual /compact is executed, confirming the hook setup itself is not the issue
  • The problem appears to be that CLAUDE_AUTOCOMPACT_PCT_OVERRIDE is not being read or applied at all in v2.1.118 for Sonnet 4.6 sessions

View original on GitHub ↗

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