CLAUDE_AUTOCOMPACT_PCT_OVERRIDE still ignored in v2.1.138 — duplicate-chain has buried the regression

Resolved 💬 3 comments Opened May 9, 2026 by stevenfreedman Closed May 9, 2026

Summary

CLAUDE_AUTOCOMPACT_PCT_OVERRIDE does not control the auto-compaction threshold in any v2.1.x release I've tested (v2.1.79 → v2.1.138). The harness uses a hard-coded internal threshold around ~78–85% regardless of the env value.

Two issues that filed this exact bug (#36381, #31806) were auto-closed as duplicates of each other and of older closed dups without ever being patched. Three sibling issues describing the same root cause are still OPEN: #18264, #18152, #19018. The duplicate-chain has effectively buried this for 2+ months.

Filing a fresh issue with v2.1.138 evidence so the regression is visible again. Please don't auto-close as a duplicate — the priors are all closed-without-fix.

Environment

  • Claude Code version: 2.1.138 (also confirmed: 2.1.137, 2.1.136, 2.1.133)
  • Plan: Max
  • OS: Linux 6.17.0-23-generic (Ubuntu)
  • Shell: bash (zsh exhibits the same)

Reproduction

  1. Set CLAUDE_AUTOCOMPACT_PCT_OVERRIDE=40 in ~/.claude/settings.json env block (or shell profile).
  2. Verify it's read by the harness: in a hook, log process.env.CLAUDE_AUTOCOMPACT_PCT_OVERRIDE — value "40" is correctly visible.
  3. Use a long, multi-subagent session until CC's own statusline shows context > 40%.
  4. Observe: auto-compaction does NOT fire at 40%. In my session today, real native context_window.used_percentage (the same field CC's statusline uses) crossed 40%, 50%, 60% with zero auto-compaction.
  5. Compaction eventually fires somewhere between ~78% and ~85% (the apparent hard-coded threshold from #31806's title), or doesn't fire and produces "Context limit reached" (#19018).

Evidence

  • Compaction-log on disk shows long gaps between auto-fires in high-volume sessions despite env override = 40.
  • Binary MD5s of v2.1.136, v2.1.137, v2.1.138 differ (genuine new builds), but none of the v2.1.123 → v2.1.138 release notes mention compact/autocompact. No release-line claims to address this.

Issue chain (please don't dup-close)

| # | State | Title |
|---|---|---|
| #36381 | CLOSED dup | CLAUDE_AUTOCOMPACT_PCT_OVERRIDE not triggering at threshold (v2.1.79) |
| #31806 | CLOSED dup | CLAUDE_AUTOCOMPACT_PCT_OVERRIDE cannot raise threshold above default (~83%) |
| #18264 | OPEN | autoCompact: false ignored — compaction triggers at ~78% |
| #18152 | OPEN | Turning auto-compact OFF won't allow to continue until full |
| #19018 | OPEN | "Context limit reached · /compact or /clear to continue" |
| #24856 | CLOSED | forced compact at ~85% with full context loss |
| #17292 | CLOSED | Autocompact not triggering at 90%+ |

The closed-as-duplicate chain (#36381 → #31806 → other closed dups) means the bug has no live tracking issue despite consistent reports across 6+ releases. Please leave this open until either:

  • A release-note line claims to honor the env override at the configured value, AND
  • A confirmed test (env=40, session at 41%, auto-compaction fires) passes.

Local mitigation we shipped

For anyone hitting this: a Stop hook that reads CC's native context_window.used_percentage and emits a manual-compact prompt at target − 2pp is the only reliable signal. Code lives in our toolkit at scripts/node/hooks/compact-fire-fallback.js (private repo). Happy to share if useful.

Asks

  • Reopen #36381 or treat this as the canonical tracker (whichever you prefer — just don't dup-close it again).
  • Confirm whether CLAUDE_AUTOCOMPACT_PCT_OVERRIDE is supposed to control the main session's auto-compact threshold (per docs) or only some sub-component. If only sub-component, please document the actual main-session control surface.

View original on GitHub ↗

This issue has 3 comments on GitHub. Read the full discussion on GitHub ↗