Repository navigation
fix(antigravity): normalize per-turn prompt usage at driver boundary - #41337
jieyuexing wants to merge 1 commit into
Conversation
Antigravity 1.5+ reports inputTokens without cached reads and writes. The shared ACP layer added only cachedReadTokens, so cache writes were missing from inputTokens and cacheCreationTokens was clamped below the real value. Normalize usage in the Antigravity driver before it enters the shared conversion, and drop the geminiPromptUsage special case from the provider-agnostic ACP adapter. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
|
No actionable comments were generated in the recent review. Walkthrough
Merge Risk:
|
Note
Drafted by Claude Sonnet 5.5 and Gemini 4 Neon in T3 Code; reviewed and posted by @jieyuexing
Problem
Follow-up to #41311 (see #41311 (comment)).
Antigravity 1.5+ reports uncached input in
PromptResponse.usage.inputTokens, omitting bothcachedReadTokensandcachedWriteTokens. Previously, shared ACP code (acpPerTurnPromptUsage) handled this via a provider-specificgeminiPromptUsageflag that only addedcachedReadTokensand missedcachedWriteTokens. BecauseTurnTokenUsageexpects total prompt input (uncached + cacheRead + cacheWrite) and clampscacheCreationTokenstoinputTokens - (cachedInputTokens ?? 0), turns with non-zerocachedWriteTokensunder-reportedinputTokensand truncatedcacheCreationTokens.Change
normalizeAntigravityPromptUsageinapps/server/src/provider/acp/AntigravityProtocol.ts, adding bothcachedReadTokens ?? 0andcachedWriteTokens ?? 0toinputTokenswhile leaving the other fields untouched.response.usageinsidemakeAntigravityAcpAdapterFlavor'sruntime.promptwrapper inapps/server/src/orchestration-v2/Adapters/AntigravityAdapterV2.ts.AcpAdapterV2Flavor.geminiPromptUsageand thegeminiUsagebranch/parameter fromacpPerTurnPromptUsageinpackages/provider-acp/src/server/adapter.ts, keeping shared ACP handling independent of provider identity.AcpAdapterV2.test.tsintoAntigravityProtocol.test.ts(unit tests fornormalizeAntigravityPromptUsage) andAntigravityAdapterV2.test.ts(driver-boundary regression test verifyingturnTokenUsageonprovider_turn.updated).Verification
upstream/main(f0d160ff1e): with synthetic{ inputTokens: 100, cachedReadTokens: 5000, cachedWriteTokens: 800 },turnTokenUsagereportedinputTokens: 5100(expected5900) andcacheCreationTokens: 100(expected800).vp test run apps/server/src/provider/acp/AntigravityProtocol.test.ts apps/server/src/orchestration-v2/Adapters/AntigravityAdapterV2.test.ts apps/server/src/orchestration-v2/Adapters/AcpAdapterV2.test.tspassed (3 files / 241 tests).vp run check:changed upstream/mainpassed across format, lint, knip, graphql, typecheck (14 packages), and tests (4 files / 243 tests).agyturn producing non-zerocachedWriteTokensor a recorded replay fixture; verified at theAntigravityAdapterV2driver boundary with mockedPromptResponse.usage.Built with Claude Sonnet 5.5 in T3 Code.