Skip to content

feat: show cache-creation (write) token total in session usage summary - #492

Open
gurjot-05 wants to merge 2 commits into
google:mainfrom
gurjot-05:feat/session-cache-creation-token-total
Open

feat: show cache-creation (write) token total in session usage summary#492
gurjot-05 wants to merge 2 commits into
google:mainfrom
gurjot-05:feat/session-cache-creation-token-total

Conversation

@gurjot-05

@gurjot-05 gurjot-05 commented Aug 19, 2026

Copy link
Copy Markdown

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 (not usageMetadata) because google.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

Testing

  • npm run build passes.

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.
@gurjot-05 gurjot-05 changed the title Feat/session cache creation token total feat: show cache-creation (write) token total in session usage summary Aug 19, 2026
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
gurjot-05 force-pushed the feat/session-cache-creation-token-total branch from b5956b8 to 9512e34 Compare August 19, 2026 20:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant