Auto-compact not triggering at CLAUDE_AUTOCOMPACT_PCT_OVERRIDE threshold
Description
CLAUDE_AUTOCOMPACT_PCT_OVERRIDE=30 is set via settings.json env, confirmed active in the environment. Sessions consistently reach 31-34% context usage without auto-compaction triggering. Manual /compact works fine.
Environment
- Claude Code 2.1.131 (also observed on 2.1.128, 2.1.129)
- Platform: WSL2 (Ubuntu), Linux 6.6.87.2-microsoft-standard-WSL2
- Model: claude-opus-4-6[1m] (1M context)
- Settings:
"env": {"CLAUDE_AUTOCOMPACT_PCT_OVERRIDE": "30"}
Expected behavior
Auto-compact should trigger when context reaches ~30% (300K tokens of 1M window).
Observed behavior
Context reaches 31-34% across multiple sessions without auto-compact firing. The env var is read correctly (confirmed via binary analysis — iF7() reads CLAUDE_AUTOCOMPACT_PCT_OVERRIDE and passes it as testPctOverride to rZ6()), but the $d_ check at end-of-turn does not trigger compaction.
Possible cause
Binary analysis of 2.1.131 shows a pfH($) gate in $d_ that was not present in earlier versions. This gate checks pfH($) && !yD$($,q) — if pfH evaluates truthy for the current model and yD$ (which checks if auto-compact window source is "env" or "settings") returns false, compaction is skipped. The env var path should make yD$ return true, but the interaction with pfH may be preventing this.
Reproduction
- Set
CLAUDE_AUTOCOMPACT_PCT_OVERRIDE=30in settings.json env - Use claude-opus-4-6[1m] model
- Run a session until context reaches 30%+
- Observe that auto-compact does not trigger (status line shows ctx% increasing past 30%)
- Manual
/compactworks normally
This issue has 2 comments on GitHub. Read the full discussion on GitHub ↗