Repository navigation
Description
Summary
Context % (usable) uses modelNativeWindow * 0.8 as the denominator, ignoring two layers of user config in Claude Code:
- Window —
autoCompactWindow(settings.json) /CLAUDE_CODE_AUTO_COMPACT_WINDOW(env) - Threshold —
CLAUDE_AUTOCOMPACT_PCT_OVERRIDE(env) /DISABLE_AUTO_COMPACT=1(env)
Ctx(u) no longer reflects "usable context before auto-compact" — defeating the widget's purpose vs. raw Context %.
Repro
| Setting | Model | Tokens | /context says |
ccstatusline shows |
|---|---|---|---|---|
autoCompactWindow: 200000 |
Opus 4.7 (1M) | 70k | ~42% (70k / 167k) | ~9% (70k / 800k) |
env.CLAUDE_AUTOCOMPACT_PCT_OVERRIDE: "60" |
Sonnet 4.5 (200k) | 96k | 80% (96k / 120k) | 60% (96k / 160k) |
env.DISABLE_AUTO_COMPACT: "1" |
any | — | % of full window | % of 80% of window |
167k = 200k − 33k reserve — the actual trigger formula, reverse-engineered in anthropics/claude-code#46331. Same bug class as jarrodwatts/claude-hud#540.
Root cause
src/utils/model-context.ts:12 hard-codes const USABLE_CONTEXT_RATIO = 0.8;. getContextConfig() multiplies the native window by it unconditionally — never reads autoCompactWindow from settings.json, never reads the three env vars.
Suggested fix
Resolve effective window and threshold at render time, mirroring CC's priority:
Effective window:
process.env.CLAUDE_CODE_AUTO_COMPACT_WINDOWautoCompactWindowfrom~/.claude/settings.jsonand.claude/settings.json(project > global)- Native model window
Usable ratio within that window:
process.env.DISABLE_AUTO_COMPACT === '1'→ 1.0process.env.CLAUDE_AUTOCOMPACT_PCT_OVERRIDE(1–100, CC clamps to ~0.83) → value/100- Default:
(window − 33k) / windowto match CC'swindow − maxOutput(20k) − buffer(13k), or keep 0.8 fallback
Env vars set in settings.json's env block are already exported into the CC process, so process.env is sufficient for those. autoCompactWindow requires reading settings.json.
Related
- Mismatch between context % display in ccstatusline and "autocompact in x%" #3 — original autocompact mismatch (pre-dates these overrides)
- Context display should use autocompactWindow as denominator instead of full context window jarrodwatts/claude-hud#540 — identical bug in sibling status-line project
- GrowthBook experiment tengu_amber_redwood silently reduces autocompact window to ~80k on Sonnet 200k (v2.1.92+ regression) anthropics/claude-code#46331 — reverse-engineered formula + override priority
- [FEATURE] Per-model configurable autocompact threshold anthropics/claude-code#34126 — per-model threshold request
- Add autoCompact: false setting to fully disable auto-compaction anthropics/claude-code#42149 —
autoCompact: falsesettings key request
Environment
- ccstatusline: 2.2.19
- Claude Code: 2.1.143
- OS: Ubuntu 24.04.4 LTS (WSL2)
Activity
[-]Context % (usable) widget hard-codes 80% threshold, ignores `CLAUDE_AUTOCOMPACT_PCT_OVERRIDE` / `DISABLE_AUTO_COMPACT`[/-][+]Context % (usable) widget ignores `autoCompactWindow`, `CLAUDE_AUTOCOMPACT_PCT_OVERRIDE`, and `DISABLE_AUTO_COMPACT`[/+][-]Context % (usable) widget ignores `autoCompactWindow`, `CLAUDE_AUTOCOMPACT_PCT_OVERRIDE`, and `DISABLE_AUTO_COMPACT`[/-][+]Context % (usable) ignores `autoCompactWindow` and compaction env overrides[/+]