@devries-cameron20 / t3code Mirror · read-only / commits / 602e5b32f5
Fork 0

The best way to control Claude Code, Codex and more from any computer or phone

Mirrored from https://github.com/Camo67/t3code.git

Synced Nov 21, 04:45 UTC

fix(antigravity): stop double-counting thinking tokens in turn output usage (#39686)

Co-authored-by: Julius Marminge <julius0216@outlook.com>

MusseJusse committed Nov 20, 2026 at 12:33 UTC 602e5b32f58e14e02b5885222f1c172049650312
2 files changed +12 -14
apps/server/src/orchestration-v2/Adapters/AcpAdapterV2.test.ts
+10 -10
@@ -206,16 +206,16 @@ describe("acpPerTurnPromptUsage", () => {
206 reasoningTokens: 3,
207 },
208 );
209 - // Antigravity 1.4.5: its harness reports prompt tokens without the 24 cached ones.
209 + // Antigravity 1.5+: inputTokens excludes cached reads, while outputTokens already includes thinking.
210 assert.deepEqual(
211 acpPerTurnPromptUsage(
212 {
213 - inputTokens: 42,
214 - outputTokens: 3,
215 - totalTokens: 54,
216 - cachedReadTokens: 24,
213 + inputTokens: 2181,
214 + outputTokens: 23,
215 + totalTokens: 14323,
216 + cachedReadTokens: 12119,
217 cachedWriteTokens: 0,
218 - thoughtTokens: 9,
218 + thoughtTokens: 19,
219 },
220 false,
221 "completed",
@@ -225,11 +225,11 @@ describe("acpPerTurnPromptUsage", () => {
225 usageScope: "main_agent",
226 usageStatus: "complete",
227 hasSubagents: false,
228 - inputTokens: 66,
229 - outputTokens: 12,
230 - cachedInputTokens: 24,
228 + inputTokens: 14300,
229 + outputTokens: 23,
230 + cachedInputTokens: 12119,
231 cacheCreationTokens: 0,
232 - reasoningTokens: 9,
232 + reasoningTokens: 19,
233 },
234 );
235 });
packages/provider-acp/src/server/adapter.ts
+2 -4
@@ -340,9 +340,7 @@ export function acpPerTurnPromptUsage(
340 const inputTokens = geminiUsage
341 ? usage.inputTokens + (usage.cachedReadTokens ?? 0)
342 : usage.inputTokens;
343 - const outputTokens = geminiUsage
344 - ? usage.outputTokens + (usage.thoughtTokens ?? 0)
345 - : usage.outputTokens;
343 + const outputTokens = usage.outputTokens;
344 // TurnTokenUsage contract: input includes cache read + write and reasoning
345 // is a subset of output, so clamp counters that exceed their parent and
346 // drop the ones the agent left unset. Cache writes are capped at whatever
@@ -657,7 +655,7 @@ export interface AcpAdapterV2Flavor {
655 * leaves usage semantics open, so this stays unset until proven live.
656 */
657 readonly reportsPerTurnPromptUsage?: boolean;
660 - /** Gemini-style usage: inputTokens leaves out cachedReadTokens, outputTokens leaves out thoughtTokens. */
658 + /** Antigravity 1.5+ usage: inputTokens leaves out cachedReadTokens, while outputTokens already includes thoughtTokens. */
659 readonly geminiPromptUsage?: boolean;
660 /**
661 * Fails a dispatched prompt after this long with no update for its session while no