fix(usage): read Gemini usageMetadata out of the antigravity response envelope - #10430
fix(usage): read Gemini usageMetadata out of the antigravity response envelope#10430rqzbeh wants to merge 13 commits into
Conversation
… envelope
Port decolua/9router#59d858b: antigravity/gemini-cli wrap non-streaming
payloads in { response: {...} }, so extractUsageFromResponse only saw the
top-level usageMetadata and every non-streaming antigravity request logged
zero usage (IN 0 | OUT 0) and zeroed usage-dashboard rows. Top-level
metadata keeps priority; OpenAI/Claude branches untouched.
…avity-usage-envelope
…avity-usage-envelope
…avity-usage-envelope
…age-envelopefix/antigravity-usage-envelope)
|
Thanks for the port, @rqzbeh — this is a clean, surgical fix. Verified locally against No changes requested — this looks merge-ready as-is. One small thought for a possible follow-up (not blocking this PR): the Gemini branch of Nice work on tracing this all the way to the upstream issue and matching the existing envelope-read pattern. |
…avity-usage-envelope
|
Thanks @diegosouzapw — good call on that gap. I've opened the follow-up as a separate PR: #10465 (fix(usage): surface Gemini cachedContentTokenCount as cached_tokens). It adds One note: the branch is stacked on the #10430 branch, so the PR diff currently includes the envelope fix too — once #10430 merges, #10465 reduces to just its own delta. Happy to rebase onto |
…avity-usage-envelope
…avity-usage-envelope
…avity-usage-envelope
…avity-usage-envelope
Summary
Non-streaming Antigravity / gemini-cli requests wrapped their payloads in
{ response: { ... } }, butextractUsageFromResponseonly tested thetop-level
usageMetadata— so every non-streaming antigravity requestlogged
IN 0 | OUT 0and zeroed rows in the usage dashboard. This is theport of upstream
decolua/9router#59d858b("fix(usage): read GeminiusageMetadata out of the antigravity response envelope").
The fix reads
responseBody.usageMetadata || responseBody.response?.usageMetadata(the same envelope read the streaming path and
usageTrackingalready use);top-level metadata keeps priority and the OpenAI / Claude branches are
untouched.
Related Issues
Validation
npm run lint— no issues in changed files (repo-wide baseline noise documented)Tests Added Or Updated
tests/unit/usage-extractor.test.ts: two new tests —usageMetadatafrom the antigravity{ response: {...} }envelopeusageMetadataover the envelope when both are presentCoverage Notes
usageTracking.ts) already unwrapped the envelope; thiscloses the non-streaming gap (
chatCore.ts:4367+ semantic-cache path).Reviewer Notes
against the OmniRoute codebase before implementing.