claude-code - 💡(How to fix) Fix Expose thinking token counts in statusline JSON input

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…

The JSON object passed to custom statusline scripts (context_window) includes total_input_tokens and total_output_tokens, but does not include thinking/reasoning tokens. This makes it impossible to calculate accurate session cost from a statusline script — on Opus, thinking tokens are often the dominant cost component.

Root Cause

  • The statusline is the only in-session cost indicator available to users (there is no /usage or /cost command)
  • On Opus, thinking tokens can be 3-10x the visible output tokens and are often the single largest cost component
  • Users building custom statuslines for cost tracking (which Claude Code encourages via the statusline API) get a misleadingly low number
  • The model name is already available in the statusline JSON, so with thinking tokens exposed, scripts can apply correct per-model pricing for all three token types

Code Example

{
  "total_input_tokens": 150000,
  "total_output_tokens": 5000,
  "used_percentage": 23
}

---

{
  "total_input_tokens": 150000,
  "total_output_tokens": 5000,
  "total_thinking_tokens": 42000,
  "used_percentage": 23
}
RAW_BUFFERClick to expand / collapse

Summary

The JSON object passed to custom statusline scripts (context_window) includes total_input_tokens and total_output_tokens, but does not include thinking/reasoning tokens. This makes it impossible to calculate accurate session cost from a statusline script — on Opus, thinking tokens are often the dominant cost component.

Current behavior

The context_window object provides:

{
  "total_input_tokens": 150000,
  "total_output_tokens": 5000,
  "used_percentage": 23
}

A statusline script can compute cost from these, but the result significantly underestimates actual spend because thinking tokens are invisible.

Requested change

Add total_thinking_tokens to the context_window object passed to statusline scripts:

{
  "total_input_tokens": 150000,
  "total_output_tokens": 5000,
  "total_thinking_tokens": 42000,
  "used_percentage": 23
}

The data already exists — the API response includes thinking token counts. Claude Code just needs to accumulate them and surface them in the statusline input, the same way it already does for input and output tokens.

Why this matters

  • The statusline is the only in-session cost indicator available to users (there is no /usage or /cost command)
  • On Opus, thinking tokens can be 3-10x the visible output tokens and are often the single largest cost component
  • Users building custom statuslines for cost tracking (which Claude Code encourages via the statusline API) get a misleadingly low number
  • The model name is already available in the statusline JSON, so with thinking tokens exposed, scripts can apply correct per-model pricing for all three token types

Related issues

  • #49320 — requests thinking_tokens in the raw API usage response (API-level; this issue is about the statusline data pipeline)
  • #31585 — requests thinking tokens in OpenTelemetry metrics (telemetry-level)
  • #49745 — broader cost estimation blind spots (thinking tokens are one contributing factor)

This is a narrowly scoped change: accumulate thinking tokens from API responses and include them in the existing statusline JSON object.

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