mirror of
https://github.com/AgentSeal/codeburn.git
synced 2026-11-29 10:43:47 +00:00
fix(antigravity): apply the output-total rule to a total of 0 as well
A record with output total 0 beside a nonzero thinking/response split kept the split, against the total-wins rule. Antigravity never writes that shape: a read-only scan of every gen_metadata row in the owner's Antigravity conversation databases (166 rows, 9 files) found 165 whose split sums exactly to the total and none with a zero total beside a nonzero split. The .pb conversations are readable only through the running app, so they were not scanned. A total of 0 now caps the split at 0 like any other total.
This commit is contained in:
parent
8ea9ba8966
commit
93af1add2a
2 changed files with 8 additions and 6 deletions
|
|
@ -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]
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
})
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue