Skip to content

CLAUDE_AUTOCOMPACT_PCT_OVERRIDE silently stopped taking effect after 2026-07-14 (v2.1.220) #82761

Open

Description

@Jordanm37

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 via setx (HKCU\Environment), not via settings.json (settings.json env is known not to work for this knob)
  • "autoCompactEnabled": true in ~/.claude/settings.json
  • No DISABLE_AUTO_COMPACT / DISABLE_COMPACT set 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

  1. setx CLAUDE_AUTOCOMPACT_PCT_OVERRIDE 33, restart the terminal
  2. Start a session on claude-opus-5[1m], confirm the variable is in the process environment
  3. Grow context past 330k tokens
  4. Observe: no auto-compaction; compactMetadata in the session .jsonl records only trigger: "manual" entries

Activity

  1. raddue commented on Sep 7, 2026

    @raddue

    Haven't tested CLAUDE_AUTOCOMPACT_PCT_OVERRIDE directly, 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-based autoCompactWindow knob instead" as a workaround: that one is also unreliable at fleet scale, independent of this specific env var.

    I parsed compactMetadata out of 92 trigger: "auto" compaction events across 6+ concurrent repos/sessions on my machine (2026-08-01 to 2026-09-07), all with a single autoCompactWindow value configured via user-level settings.json. Actual preTokens at 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/Gkn per the reverse-engineering in #70477) rather than treating them as two independent regressions.

  2. Burlesque1 commented on Oct 19, 2026

    @Burlesque1

    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:

    // threshold computation still honors the override:
    function c5(effectiveWindow, opts) {
      const ceiling = effectiveWindow - 13000;              // summary buffer
      const pct = opts.testPctOverride;                     // from CLAUDE_AUTOCOMPACT_PCT_OVERRIDE
      if (pct !== undefined && !isNaN(pct) && pct > 0 && pct <= 100)
        return Math.min(Math.floor(effectiveWindow * (pct / 100)), ceiling);
      return ceiling;
    }
    
    // ...but the worker-state path passes testPctOverride: void 0 unconditionally:
    function resolveLevel(tokens, model, ctx, state) {
      if (state !== undefined)
        return gwe(tokens, state.effectiveWindow, {
          enabled: state.enabled,
          precomputeBufferFraction: XPE,
          testPctOverride: void 0,        // <-- override discarded
          testBlockingOverride: void 0
        }, ilr(model), state.threshold);
      ...
    }
    
    // ...and the fork path does the same on purpose (its own telemetry says so):
    function withoutOverride(model, ctx) {
      return c5(c9(model, ctx), { ...ope(model, ctx), testPctOverride: void 0 });
    }
    // telemetry message: "autocompact: not compacting the <agentType> fork:
    //  it ignores CLAUDE_AUTOCOMPACT_PCT_OVERRIDE, and ..."

    Observed behavior on 2.1.299 with CLAUDE_AUTOCOMPACT_PCT_OVERRIDE=80 and a 400000-token window: the session's autocompact_state frame reports threshold: 367000 — exactly the default window - min(maxOutputTokens, 20000) - 13000 formula with no override applied — while the same settings file and process env are confirmed correct (env inside 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_state schema 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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions