[FEATURE] Expose the effective auto-compact window in the statusLine JSON
Preflight Checklist
- [x] I have searched existing requests and this feature hasn't been requested yet
- [x] This is a single feature request (not multiple features)
Problem Statement
When an auto-compact window is set, for example with /autocompact 400k, the statusLine JSON does not reflect it. A status line therefore cannot show how close the conversation is to compaction.
context_window.context_window_size is always the model's full window, and the status line docs state that used_percentage "always measures against the model's full context window." With an auto-compact window set, that percentage no longer indicates when compaction will run.
Example: Opus on a 1M window with autoCompactWindow: 400000. At 392k tokens, the status line shows 39% used. Compaction is about 8k tokens away.
The value cannot be recovered reliably from outside the session, because it is per-session state. Each session resolves its window once at startup, from --autocompact, CLAUDE_CODE_AUTO_COMPACT_WINDOW, or autoCompactWindow in settings. After that, only /autocompact run in that same session changes it. The settings file is shared, though. When session A runs /autocompact, it rewrites autoCompactWindow in the user settings file, but session B keeps compacting at its startup value. A status line command sees only its stdin JSON, an environment fixed at launch, and files on disk. None of these holds the value session B actually uses.
Proposed Solution
Add the session's resolved value to context_window:
"context_window": {
"context_window_size": 1000000,
"auto_compact": {
"enabled": true,
"window": 400000,
"threshold_tokens": 400000,
"source": "settings"
}
}
windowis the effective auto-compact window for this session, after all precedence rules and caps. It is the session's own value, not the current contents of the settings file.threshold_tokensis the token count at which auto-compaction triggers. It differs fromwindowwhenCLAUDE_AUTOCOMPACT_PCT_OVERRIDEor a tuned default applies.sourceisenv,flag,settings, ordefault. A status line can use it to mark an explicit override.- When auto-compaction is off, the object is omitted or reports
enabled: false.
A single auto_compact_window number would cover most of the need. The internal autocompact_state event for remote sessions appears to carry the same values (enabled, effective_window, threshold, source), so they may already be computed.
Alternative Solutions
I tried the options available to a status line today. Each one falls short:
- Read
autoCompactWindowfrom~/.claude/settings.json. This is my current workaround. It reads and parses the settings file on every render to reconstruct a value Claude Code already holds in memory. It is correct in a single session, but wrong in every other open session after one of them runs/autocompact. It cannot see--autocompact. It also has to copy Claude Code's resolution rules: env over flag over settings scopes, the 100k–1M clamp, the cap at the model window, and the tuned defaults. These rules can change in any release. - Set
CLAUDE_CODE_AUTO_COMPACT_WINDOWinstead. The status line command inherits the variable, so the displayed value is accurate. But the variable is a hard override: while it is set,/autocompactand--autocompactstop working. - Bridge the value with hooks. No hook input carries the auto-compact window.
ConfigChangefires in every session when the settings file changes, and its input does not say which session made the change.CLAUDE_ENV_FILEis available only to a few hook events and feeds the Bash tool, not the status line. A bridge would need per-session state files and a cleanup job. - Add the field through status line configuration. The
statusLinesetting accepts onlytype,command,padding,refreshInterval, andhideVimModeIndicator. There is no way to extend the payload.
Priority
Medium - Would be very helpful
Feature Category
Interactive mode (TUI)
Use Case Example
- I set
/autocompact 400kso long sessions compact well before the 1M limit. - My status line shows context usage as a bar, a percentage, and
used/maxtokens, with colour thresholds near the limit. - I usually have several sessions open. When I change the window in one of them, the others keep their old value.
- With this field, each session's bar, percentage, and thresholds measure against the window that session will actually compact at.
Additional Context
- Related: #90212 asks to change the auto-compact window at runtime. This request is about displaying it.
- #95368 makes the same argument for
/focusstate: it lives in the running process, and a separate status line process cannot read it. One mechanism for exposing session state could cover both. - Similar request for other session state: #94299.
- Observed on Claude Code 2.1.280, macOS.
This issue has 2 comments on GitHub. Read the full discussion on GitHub ↗