CLAUDE_AUTOCOMPACT_PCT_OVERRIDE not triggering at configured threshold
Resolved 💬 3 comments Opened Mar 19, 2026 by YebooLixoo Closed Mar 20, 2026
Bug Description
CLAUDE_AUTOCOMPACT_PCT_OVERRIDE=55 is set as an environment variable but auto-compaction does not trigger at 55% context usage. The main session regularly exceeds the configured threshold without compacting — observed at 67% in one session and over 80% in another before compaction finally occurred.
Environment
- Claude Code version: 2.1.79
- Model: Claude Opus 4.6 (Max plan)
- OS: macOS (Darwin 23.5.0)
- Shell: zsh
Steps to Reproduce
- Set
export CLAUDE_AUTOCOMPACT_PCT_OVERRIDE=55in~/.zshrc - Verify the variable is loaded:
echo $CLAUDE_AUTOCOMPACT_PCT_OVERRIDE→55 - Start a Claude Code session and use it until context exceeds 55%
- Observe that auto-compaction does not trigger at 55%
Expected Behavior
Auto-compaction should trigger when context window usage reaches ~55%, as configured by CLAUDE_AUTOCOMPACT_PCT_OVERRIDE.
Actual Behavior
- Context reached 67% (see screenshot) without triggering auto-compaction
- In another session, context reached over 80% before auto-compaction finally fired
- The env var appears to be ignored for the main session
Screenshot
Context at 67% with no auto-compaction triggered:
<img width="816" height="198" alt="Image" src="https://github.com/user-attachments/assets/2cd4a39f-3b6d-4144-bd69-43a82fc843f1" />
Additional Context
- The env var is confirmed set in the shell environment
CLAUDE_CODE_AUTO_COMPACT_WINDOWis not set (default)- According to the docs,
CLAUDE_AUTOCOMPACT_PCT_OVERRIDEshould apply to both main conversations and subagents - The HUD percentage comes from Claude Code's native
used_percentagefield, so the reported percentage should match what the compaction engine sees
This issue has 3 comments on GitHub. Read the full discussion on GitHub ↗