diff --git a/src/providers/antigravity.ts b/src/providers/antigravity.ts index 76687ee7..4bf9fbda 100644 --- a/src/providers/antigravity.ts +++ b/src/providers/antigravity.ts @@ -1011,11 +1011,12 @@ function decodePackedVarints(data: Uint8Array): number[] { } // ModelUsageStats' output total (field 3, thinking + response) wins over its -// split whenever it is set: an absent split (proto3 omits unset fields) takes -// the total as response, and a split that disagrees, even one whose thinking -// alone exceeds the total, is cut back to it. Returns [response, thinking]. +// split: an absent split (proto3 omits unset fields) takes the total as +// response, and a split that disagrees, even one whose thinking alone exceeds +// the total or one beside a total of 0, is cut back to it. Returns +// [response, thinking]. function reconcileOutputSplit(total: number, thinking: number, response: number): [number, number] { - if (total <= 0 || response + thinking === total) return [response, thinking] + if (response + thinking === total) return [response, thinking] const kept = Math.min(thinking, total) return [total - kept, kept] } diff --git a/tests/providers/antigravity.test.ts b/tests/providers/antigravity.test.ts index 3ad33df4..0f514c76 100644 --- a/tests/providers/antigravity.test.ts +++ b/tests/providers/antigravity.test.ts @@ -881,10 +881,11 @@ describe('antigravity provider helpers', () => { { chatModel: { model: 'gemini-3-pro', usage: { model: 'gemini-3-pro', inputTokens: '1000', outputTokens: '4000', responseId: 'r1' } } }, { chatModel: { model: 'gemini-3-pro', usage: { model: 'gemini-3-pro', inputTokens: '1000', outputTokens: '4000', thinkingOutputTokens: '1000', responseId: 'r2' } } }, { chatModel: { model: 'gemini-3-pro', usage: { model: 'gemini-3-pro', inputTokens: '1000', outputTokens: '100', thinkingOutputTokens: '200', responseOutputTokens: '50', responseId: 'r3' } } }, + { chatModel: { model: 'gemini-3-pro', usage: { model: 'gemini-3-pro', inputTokens: '1000', outputTokens: '0', thinkingOutputTokens: '100', responseOutputTokens: '50', responseId: 'r4' } } }, ], {}) // The output total wins over a split that disagrees, even when thinking - // alone is larger than the total. - expect(calls.map(c => [c.outputTokens, c.reasoningTokens])).toEqual([[4000, 0], [3000, 1000], [0, 100]]) + // alone is larger than the total, or the total is 0. + expect(calls.map(c => [c.outputTokens, c.reasoningTokens])).toEqual([[4000, 0], [3000, 1000], [0, 100], [0, 0]]) expect(calls[0]!.costUSD).toBeCloseTo(calls[1]!.costUSD, 12) expect(calls[0]!.costUSD).toBeGreaterThan(0.04) })