CLAUDE_AUTOCOMPACT_PCT_OVERRIDE cannot raise threshold above default (~83%)
Summary
CLAUDE_AUTOCOMPACT_PCT_OVERRIDE is documented as allowing users to control when auto-compaction triggers, but it can only lower the threshold below the default — never raise it. Setting it to 95 (meaning "compact at 95% usage") has no effect because of a Math.min clamp in the threshold calculation.
Root cause
In the minified source, the threshold function (deobfuscated) does:
function getAutoCompactThreshold(model) {
let effectiveWindow = getEffectiveWindow(model);
let defaultThreshold = effectiveWindow - 13000; // ~83.5% of 200k
let override = process.env.CLAUDE_AUTOCOMPACT_PCT_OVERRIDE;
if (override) {
let pct = parseFloat(override);
if (!isNaN(pct) && pct > 0 && pct <= 100) {
let userThreshold = Math.floor(effectiveWindow * (pct / 100));
return Math.min(userThreshold, defaultThreshold); // ← override silently capped
}
}
return defaultThreshold;
}
Math.min(userThreshold, defaultThreshold) means any value above ~83% is ignored.
Expected behavior
Setting CLAUDE_AUTOCOMPACT_PCT_OVERRIDE=95 should trigger auto-compaction at 95% context usage, not ~83%. If there's a safety reason for the buffer, it should be documented — and the env var should either work as advertised or not exist.
Reproduction
- Set
"env": { "CLAUDE_AUTOCOMPACT_PCT_OVERRIDE": "95" }in~/.claude/settings.json - Start a long conversation
- Observe compaction triggers at ~80-85%, not 95%
This issue has 3 comments on GitHub. Read the full discussion on GitHub ↗