Skip to content

fix(genkit): record cached and reasoning tokens under canonical metric names - #2813

Open
alexcastgonz (pcbeingused333) wants to merge 1 commit into
braintrustdata:mainfrom
pcbeingused333:fix/genkit-usage-metric-names
Open

alexcastgonz (pcbeingused333) wants to merge 1 commit into
braintrustdata:mainfrom
pcbeingused333:fix/genkit-usage-metric-names

Conversation

@pcbeingused333

Copy link
Copy Markdown
Contributor

The Genkit instrumentation logged usage.cachedContentTokens and usage.thoughtsTokens as cached_tokens and reasoning_tokens. The canonical names used by the other Google instrumentation (and read by Braintrust for cost/usage) are prompt_cached_tokens and completion_reasoning_tokens, so Genkit spans lost cache and reasoning usage.

Fix: parseGenkitUsageMetrics now emits prompt_cached_tokens and completion_reasoning_tokens, matching google-genai-instrumentation.ts. Changeset added.

Test: new case in genkit-instrumentation.test.ts checks the logged span metrics contain the canonical keys and not the old ones (fails before, passes after).


This change was prepared with the assistance of an AI coding agent (Claude); the submitter is responsible for the contribution.

…c names

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>

This branch has not been deployed

No deployments
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