Skip to content

Context % (usable) ignores autoCompactWindow and compaction env overrides #389

Closed

Description

@pedropaulovc

Summary

Context % (usable) uses modelNativeWindow * 0.8 as the denominator, ignoring two layers of user config in Claude Code:

  1. Window — autoCompactWindow (settings.json) / CLAUDE_CODE_AUTO_COMPACT_WINDOW (env)
  2. 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:

  1. process.env.CLAUDE_CODE_AUTO_COMPACT_WINDOW
  2. autoCompactWindow from ~/.claude/settings.json and .claude/settings.json (project > global)
  3. Native model window

Usable ratio within that window:

  1. process.env.DISABLE_AUTO_COMPACT === '1' → 1.0
  2. process.env.CLAUDE_AUTOCOMPACT_PCT_OVERRIDE (1–100, CC clamps to ~0.83) → value/100
  3. Default: (window − 33k) / window to match CC's window − 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

Environment

  • ccstatusline: 2.2.19
  • Claude Code: 2.1.143
  • OS: Ubuntu 24.04.4 LTS (WSL2)

Activity

  1. changed the title [-]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`[/+] on May 19, 2026
  2. changed the title [-]Context % (usable) widget ignores `autoCompactWindow`, `CLAUDE_AUTOCOMPACT_PCT_OVERRIDE`, and `DISABLE_AUTO_COMPACT`[/-] [+]Context % (usable) ignores `autoCompactWindow` and compaction env overrides[/+] on May 19, 2026
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

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions