Repository navigation
feat(chat): tokens per turn and per bot, never in money - #73
Merged
Merged
Conversation
Each turn item keeps the tokens of Claude Code's result usage (new input, cache written, cache read, output), which is the sum of the turn's requests. The chat shows them on the turn's line and usage.tokens sums them per bot for a new part of the usage dialog, over today, 7 days, 30 days or all time. The dollar cost is gone from the app: total_cost_usd is API pricing and adds up the whole process, not the turn, so the tooltip was wrong after the first turn. Spec 8.7 is new; 19 records the real test.
# Conflicts: # docs/spec.md
httpsphl
enabled auto-merge
September 30, 2026 21:56
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
turnitem keepstokens(input,cacheWrite,cacheRead,output) from theusageof Claude Code'sresult, which is the sum of that turn's requests.costUsdis gone.usage.tokens {since}sums turns per bot (archived bots included). The usage dialog gets a "Tokens by bot" part: today, 7 days, 30 days, all time, with the total.0011adds a partial index for turn items by time.Why no money
total_cost_usdis API list price and adds up the whole process, not the turn, so the old tooltip was wrong after the first turn; plan users do not pay it either.Checked against real Claude Code (2.1.284)
A
claude -pstream-json process with two turns, one usingRead:result.usageis the sum of the turn's requests (input_tokens18 = 10 + 8,cache_read_input_tokens46703 = 21692 + 25011) and starts over each turn;modelUsageandtotal_cost_usdaccumulate. Not verified: whether subagent tokens are in thatusage(listed in spec 19).Manual test