feat: show cache-creation (write) token total in session usage summary - #492
Open
gurjot-05 wants to merge 2 commits into
Open
feat: show cache-creation (write) token total in session usage summary#492gurjot-05 wants to merge 2 commits into
gurjot-05 wants to merge 2 commits into
Conversation
The event tab's per-event usage view already renders every usageMetadata field, but the "Usage Summary for Session" totals aggregated only prompt, candidates, and total tokens. Cached-content (cache-read) and thoughts (reasoning) tokens were invisible at the session level, even though they matter for cost tracking. Sum cachedContentTokenCount and thoughtsTokenCount across the session's events and add "Total Cached Content Tokens" and "Total Thoughts Tokens" rows to the session summary. Each row renders only when its total is greater than zero, so sessions without caching or reasoning are unchanged.
Extends the session usage summary with a "Total Cache Creation Tokens" row for prompt-cache *write* tokens, complementing the cache-read and reasoning totals. Cache-write is read from the event itself (event.cacheCreationTokenCount) rather than usageMetadata, because google.genai's usage type forbids extra fields; read/reasoning remain usageMetadata fields. The row renders only when the total is greater than zero, so it stays inert until a backend that serializes the field is in use.
gurjot-05
force-pushed
the
feat/session-cache-creation-token-total
branch
from
August 19, 2026 20:17
b5956b8 to
9512e34
Compare
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
Adds a "Total Cache Creation Tokens" row (prompt-cache write) to the Event tab's session usage summary.
Why
Complements the cache-read + reasoning session totals. Cache-write is read from
event.cacheCreationTokenCount(notusageMetadata) becausegoogle.genai's usage type forbids extra fields, so the backend exposes it on the serializable event. The row renders only when> 0, so it stays inert until a backend that serializes the field is deployed.Related PRs
cacheCreationTokenCountinto the event so this row has data to show. Please merge feat: total cached-content and reasoning tokens in session usage summary #491 and the backend PR first (or together).Testing
npm run buildpasses.