Context and Cost Threshold - patrickbykov/claude-telemetry-widget GitHub Wiki
Context and cost threshold
TL;DR: Context means every token the request carried. The widget warns at 150k (warn) and 300k (bad). This is a cost heuristic (H), not the point where Claude Code auto-compacts.
Context size
ctx = inp + cr + c5 + c1
This counts all input tokens: fresh, cached and newly cached. It is the "Nk context" number in the menu.
Example: 2,000 + 140,000 + 0 + 8,000 = 150,000 → shown as "150k context".
Cost threshold (H)
| Level | Rule | Default |
|---|---|---|
| ok | ctx <= ctx_big_tokens |
≤ 150k |
| warn | ctx > ctx_big_tokens |
> 150k |
| bad | ctx > 2 × ctx_big_tokens |
> 300k |
To change it, edit ctx_big_tokens in config.json. It can be a single number (applies to all
models and context windows) or a per-model, per-window dict — see Smart zone
below for how that resolves.
Why 150k and not 200k?
Some setups have a hard 200k context window: Opus 4.6, Bedrock/Foundry, or CLAUDE_CODE_DISABLE_1M_CONTEXT=1. With the warning at 200k, those sessions would auto-compact before the warning could ever fire. At 150k, you get a warning first.
Smart zone (H)
A second, lower threshold (ctx_smart_tokens) past which answer quality tends to degrade, not
just cost — a practitioner heuristic (~100k-150k tokens), not an Anthropic-documented number. It
shows as a 🔵 info row in "Needs attention": visible, but it does not raise the menu-bar
severity dot, and it's shown alongside (never instead of) the cold-cache warning.
Both ctx_smart_tokens and ctx_big_tokens resolve per model and per context window (200k vs
native 1M), because a 1M-window session can run far past 150k before cost or compaction become a
concern, but quality degradation starts at roughly the same token count either way. Window
detection, in order: Claude Code's own statusline.json snapshot (saved per session by
statusline-wrap.sh), then "did this session's peak context exceed 200k" if no snapshot exists,
then 200k.
The real auto-compact point (D)
| Context window | Auto-compact fires near |
|---|---|
| Standard 200k | ~200k |
| Native 1M | ~967k |
Prices don't jump at either point. Compaction is about window space. The cost threshold is about money: every request re-reads the whole context, so a big context costs more on every turn.
Next: Cache TTL →