Repository navigation
Description
Summary
CLAUDE_AUTOCOMPACT_PCT_OVERRIDE stopped taking effect. It worked until 2026-07-14, then silently became a no-op. The variable is still present in the CLI binary's string table, autoCompactEnabled is true, and the variable is confirmed present in the running process's environment — but auto-compact no longer fires at the overridden threshold.
Environment
- Claude Code
2.1.220(native Windows binary, npm install) - Windows 11 Pro 26200
- Model:
claude-opus-5[1m](1M context) CLAUDE_AUTOCOMPACT_PCT_OVERRIDE=33, set as a persistent user environment variable viasetx(HKCU\Environment), not viasettings.json(settings.jsonenvis known not to work for this knob)"autoCompactEnabled": truein~/.claude/settings.json- No
DISABLE_AUTO_COMPACT/DISABLE_COMPACTset anywhere; no hook invokes/compact
Confirmed inherited by the running CLI process:
$ env | grep AUTOCOMPACT
CLAUDE_AUTOCOMPACT_PCT_OVERRIDE=33
Evidence
I parsed every compactMetadata record out of ~/.claude/projects/*/*.jsonl (159 compaction events total: 48 trigger: "auto", 111 trigger: "manual").
While the override worked — auto-compactions fire at ~32.5% of the 1M window, exactly as configured:
2026-07-10T14:22 auto 344,052
2026-07-10T22:12 auto 325,687
2026-07-12T14:48 auto 323,840
2026-07-13T03:45 auto 325,359
2026-07-13T04:05 auto 325,844
2026-07-14T02:23 auto 324,546
2026-07-14T03:47 auto 323,801 <- last auto-compaction ever recorded
(For contrast, auto-compactions before the override was set fired at ~967k–1,007k, i.e. the default ~97% threshold.)
After 2026-07-14 — zero trigger: "auto" events in 17 days, across all projects, despite sessions running well past the 33% mark:
2026-07-28T16:22 manual 511,877 (51% of window — should have auto-compacted at ~330k)
2026-07-29T12:51 manual 383,700
2026-07-30T02:23 manual 367,200
2026-07-31T00:36 manual 338,741
2026-07-31T00:55 manual 450,047 (45% of window)
Every one of those is a /compact I typed by hand. Several exceed the configured 33% threshold by a wide margin with no auto-compaction in between.
Note this is specifically an override regression, not a claim that auto-compaction is broken outright: no session since 2026-07-14 reached the default ~95% trigger (max was 512k / 51%), so default-threshold behaviour is untested here.
Secondary observation
/context on 2.1.220 shows no auto-compact buffer row and no threshold marker — categories are System prompt / System tools / Custom agents / Memory files / Skills / Messages / Free space only. I don't know whether that row was intentionally removed from the display or whether its absence reflects auto-compact not being armed.
Expected
With CLAUDE_AUTOCOMPACT_PCT_OVERRIDE=33 on a 1M-context model, auto-compaction fires at ~330k tokens.
Actual
No auto-compaction at any threshold; context grows unbounded until compacted by hand.
Reproduction
setx CLAUDE_AUTOCOMPACT_PCT_OVERRIDE 33, restart the terminal- Start a session on
claude-opus-5[1m], confirm the variable is in the process environment - Grow context past 330k tokens
- Observe: no auto-compaction;
compactMetadatain the session.jsonlrecords onlytrigger: "manual"entries
Activity
raddue commentedon Sep 7, 2026
Haven't tested
CLAUDE_AUTOCOMPACT_PCT_OVERRIDEdirectly, so I can't confirm the exact regression window here — but I want to flag adjacent evidence for anyone reading this issue and considering "switch to the token-basedautoCompactWindowknob instead" as a workaround: that one is also unreliable at fleet scale, independent of this specific env var.I parsed
compactMetadataout of 92trigger: "auto"compaction events across 6+ concurrent repos/sessions on my machine (2026-08-01 to 2026-09-07), all with a singleautoCompactWindowvalue configured via user-levelsettings.json. ActualpreTokensat auto-trigger ranged 370,799-828,136 (2.2x spread), with a dominant cluster around ~539-545k that never matches any value I configured (only ever 400000, more recently 300000). Full data and methodology on #75335 (comment: #75335 (comment)).Claude Code version 2.1.263 — well past the 2026-07-14/v2.1.220 break point reported here, so if the intent was "the token-window path still works even though the pct-override path broke," that doesn't match what I'm seeing on the window path either, on a materially later version. Worth someone checking whether these share a root cause (e.g. the same internal "effective window" resolution logic feeding both
_ke/Gknper the reverse-engineering in #70477) rather than treating them as two independent regressions.Burlesque1 commentedon Oct 19, 2026
Still reproducible on 2.1.299 (macOS, desktop app worker, but the mechanism below is version-level). Adding decompiled evidence that pinpoints where the override is dropped.
The override is read and parsed correctly, and the threshold formula still implements it — but at least two call sites explicitly void it before use:
Observed behavior on 2.1.299 with
CLAUDE_AUTOCOMPACT_PCT_OVERRIDE=80and a 400000-token window: the session'sautocompact_stateframe reportsthreshold: 367000— exactly the defaultwindow - min(maxOutputTokens, 20000) - 13000formula with no override applied — while the same settings file and process env are confirmed correct (envinside the worker shows the variable; the threshold shown in the usage panel is 92%, not the configured 76%).So on current versions the variable is parsed but never reaches the compaction decision on the main worker path. The string table still documents it ("lowered further by CLAUDE_AUTOCOMPACT_PCT_OVERRIDE when set" in the
autocompact_stateschema description), which makes the silent ignore particularly misleading — the worker schema claims the override applies while the code path voids it.Happy to pull the exact call graph for other paths (remote/bridge, subagents) if useful — this matches #70477's observation that attached sessions ignore the override as well.