[BUG] /usage session Breakdown "Output" undercounts by ~20x — only counts plain text blocks, drops tool_use and thinking tokens
Preflight Checklist
- [x] I have searched existing issues and this hasn't been reported yet (closest are #10259 and #22686, but those describe a different root cause — see below)
- [x] This is a single bug report
- [x] I am using the latest version of Claude Code
What's Wrong?
The /usage command's "This session" Breakdown panel shows a per-model token table (Input / Output / Cache read / Cache write). For a session using Claude Fable 5.1, the panel reported:
Input 1.2k
Output 2.7k
Cache read 7.2M
Cache write 273.6k
I reconstructed the same session's true totals directly from the session JSONL transcript (~/.claude/projects/<project>/<session-id>.jsonl), deduplicating by message.id (the transcript logs several lines per billed API response — a wrinkle worth documenting separately, but handled here). Across 49 unique billed messages:
input_tokens: 1,208 (matches panel's 1.2k)
output_tokens: 56,036 (panel showed 2.7k — off by ~20x)
cache_creation (1h TTL): 273,555 (matches panel's 273.6k)
cache_read_input_tokens: 7,207,538 (matches panel's 7.2M)
Three of the four fields match the panel almost exactly, confirming the transcript data is trustworthy and the panel is drawing from the same underlying data for those three — only Output diverges, and by a large margin.
Breaking the real 56,036 output tokens down by content-block type:
| Content type | Approx tokens |
|---|---|
| Plain text (visible prose) | ~1,800 (close to the panel's displayed 2.7k) |
| tool_use blocks (Edit/Write/Bash/Agent tool calls) | ~4,400+ (char-based estimate, likely undercounts real tokenization) |
| Extended thinking (usage.output_tokens_details.thinking_tokens, always-on for Fable 5.1) | 20,604 (exact, from the usage object) |
| Remainder (likely additional tool_use tokens my char-estimate undercounts) | ~29,000 |
This strongly suggests the Breakdown panel's Output figure counts only plain text content blocks and silently excludes tool_use block content and thinking tokens — both of which are real, billed output. One especially clear example: a single Agent tool_use call in this session (spawning a subagent, with a ~9,300-character prompt) alone logged output_tokens: 3,475 — more than the panel's entire session total of 2.7k.
This is a different bug from #10259 / #22686. Those describe the JSONL itself recording an intermediate streaming chunk (stop_reason: null, output_tokens: 1) instead of the final response. I checked for that signature in this transcript and it's absent — zero "stop_reason":null entries, and individual messages correctly log large values (one message alone: output_tokens: 12876). The transcript data is accurate; the panel's aggregation/display of it for the Output row is what's wrong.
What Should Happen?
The session Breakdown's Output figure should reflect the model's true total output_tokens per usage, including tool_use block content and thinking tokens — the same total that's actually billed — not just plain-text content blocks.
Impact
For any session that's thinking-heavy (Fable 5.1 always thinks) and/or tool-call-heavy (typical agentic coding work), the displayed Output figure can be off by an order of magnitude, making the session cost breakdown and any per-model spend estimates derived from it misleading.
Steps to Reproduce
- Run a Claude Code session using
claude-fable-5-1that does substantial tool-call work (file edits, bash commands, spawning a subagent via theAgenttool). - Run
/usageand note the session Breakdown's Output figure for Fable 5.1. - Compare against the session's JSONL transcript: sum
message.usage.output_tokensacross uniquemessage.idvalues. - The transcript sum will be far higher than what
/usagedisplays; the gap corresponds roughly totool_useblock content plususage.output_tokens_details.thinking_tokens.
Claude Model
claude-fable-5-1
Is this a regression?
Unknown
Claude Code Version
2.1.170
Platform
Claude subscription (Pro)
Operating System
macOS (Darwin 23.6.0)
Terminal/Shell
Claude desktop app