claude-code - 💡(How to fix) Fix Expose autoCompactThreshold in statusLine JSON payload [1 participants]

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…
GitHub stats
anthropics/claude-code#46428Fetched 2026-04-11 06:20:33
View on GitHub
Comments
0
Participants
1
Timeline
3
Reactions
0
Participants
Timeline (top)
labeled ×3

Fix Action

Workaround

COMPACT_THRESHOLD=${BRANA_AUTOCOMPACT_THRESHOLD:-85}
UNTIL_COMPACT=$(( COMPACT_THRESHOLD - CTX_PCT ))

Works but requires the user to keep the env var in sync with any future threshold config.

Code Example

{
  "used_percentage": 42,
  ...
}

---

{
  "used_percentage": 42,
  "auto_compact_threshold": 85,
  ...
}

---

COMPACT_THRESHOLD=${BRANA_AUTOCOMPACT_THRESHOLD:-85}
UNTIL_COMPACT=$(( COMPACT_THRESHOLD - CTX_PCT ))
RAW_BUFFERClick to expand / collapse

Problem

The statusLine hook receives a JSON payload with used_percentage (the current context usage), but the auto-compact threshold is not exposed. Statusline scripts that want to show "X% until auto-compact" (matching CC's own footer text) must hardcode an assumption about the threshold.

Current payload (relevant fields):

{
  "used_percentage": 42,
  ...
}

What CC's footer shows: 42% context used · 43% until auto-compact (when threshold = 85%)

To reproduce this in a statusline script, authors must hardcode THRESHOLD=85 and compute remaining = threshold - used_percentage. If the user has a custom threshold (or if Anthropic changes the default), the statusline silently shows the wrong number.

Request

Add auto_compact_threshold (or compact_threshold_percentage) to the statusline JSON payload:

{
  "used_percentage": 42,
  "auto_compact_threshold": 85,
  ...
}

Why it matters

  • Statusline scripts can compute the correct "until compact" suffix without assumptions
  • The value is already computed by CC internally (it drives the footer text)
  • Makes the statusline payload self-consistent with the footer display

Related

  • #43981 — configurable compact threshold (if that ships, the threshold becomes user-configurable → even more important to expose it in the payload)
  • #46375 — expose activePermissionMode in statusline payload (same pattern)
  • #28999 — expose usage quota in statusline payload (same pattern)

Workaround

COMPACT_THRESHOLD=${BRANA_AUTOCOMPACT_THRESHOLD:-85}
UNTIL_COMPACT=$(( COMPACT_THRESHOLD - CTX_PCT ))

Works but requires the user to keep the env var in sync with any future threshold config.

extent analysis

TL;DR

Add auto_compact_threshold to the statusline JSON payload to allow statusline scripts to accurately compute the percentage until auto-compact.

Guidance

  • Include auto_compact_threshold in the JSON payload to provide statusline scripts with the necessary information to calculate the correct "until compact" suffix.
  • Update statusline scripts to use the auto_compact_threshold value from the payload instead of hardcoding an assumption about the threshold.
  • Consider implementing a fallback or default value for auto_compact_threshold in case it is not provided in the payload.
  • Review related issues (#43981, #46375, #28999) to ensure consistency in exposing relevant values in the statusline payload.

Example

{
  "used_percentage": 42,
  "auto_compact_threshold": 85,
  ...
}

This example shows the updated JSON payload with the auto_compact_threshold value.

Notes

The proposed solution assumes that the auto_compact_threshold value is already computed internally by CC and can be easily exposed in the statusline payload. If this is not the case, additional work may be required to calculate or retrieve this value.

Recommendation

Apply the workaround using the BRANA_AUTOCOMPACT_THRESHOLD environment variable, but consider implementing the proposed solution to add auto_compact_threshold to the statusline JSON payload for a more robust and maintainable fix. This will allow statusline scripts to accurately compute the percentage until auto-compact without requiring users to keep an environment variable in sync with any future threshold config.

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING