Settings: make the auto-compaction threshold user-configurable (compact at N% of context)
What's missing
Today the only compaction setting is autoCompactEnabled (a boolean). The threshold at which auto-compaction fires is derived internally from the model's context window (effectively ~80%) and cannot be configured. There is no settings.json key, /config option, or environment variable to say "auto-compact when the context reaches N%."
Why it matters
On the Max plan with long autonomous runs (multi-hour, multiple subagents), output quality degrades well before the window is anywhere near full — "context rot" sets in after a few hundred thousand tokens. I'd like auto-compaction to fire earlier (e.g. at 50% of a 1M window) to keep the session in a fast, fresh zone, instead of only when it's nearly full.
Today the only way to influence this is an undocumented workaround (CLAUDE_CODE_AUTO_COMPACT_WINDOW plus an internal percent override), which is brittle and changes between versions.
Scope: this is the last missing piece of the compaction lifecycle
The rest of the auto-compaction lifecycle I raised earlier (in #34925, which was closed by the stale bot rather than by an explicit decision) has since shipped, which is great:
PreCompactcan now block/guard compaction,PostCompactfires after compaction (side-effects / logging),manual/automatchers distinguish the two triggers.
The one remaining gap is a configurable threshold.
Proposed
A user-settable threshold, for example:
settings.json:"autoCompactThreshold": 50(percent of the context window), surfaced in/config, and/or- an equivalent environment variable for headless / launcher use.
Related: #6689 (disable auto-compact), #14258 / #17237 (compaction hooks).