fix(antigravity): fall back to the chat model and map Gemini 3.8 Flash placeholders (#1712)
Some checks are pending
CI / semgrep (push) Waiting to run
macOS Menubar CI / test (push) Waiting to run
Tests / test (22) (push) Waiting to run
Tests / test (22.13.0) (push) Waiting to run
Tests / test (24) (push) Waiting to run
Tests / test (26) (push) Waiting to run
Tests / test-platforms (macos-latest) (push) Waiting to run
Tests / desktop (push) Waiting to run
Tests / vscode (push) Waiting to run
Tests / test-platforms (windows-latest) (push) Waiting to run
Windows Menubar CI / check (ubuntu-latest) (push) Waiting to run
Windows Menubar CI / check (windows-latest) (push) Waiting to run

When an Antigravity response left out the model, the parser crashed on the legacy .pb path and the whole session was skipped. It now falls back to the chat's own model and passes it through the live model map.

Maps the Gemini 3.8 Flash placeholders M318/M319/M320 to the high/medium/low ids from Antigravity's model catalog, and the gemini-3-flash-a/-d family strings to gemini-3-flash-preview (LiteLLM prices, nothing hardcoded). Parse version, results cache v9 and daily cache v74 bumped so cached rows re-parse; calls and cost only rise.

Thanks @dcaldr.
This commit is contained in:
Dan Caldr 2026-10-10 11:34:13 +02:00 • committed by GitHub
parent 247957ff91
commit 26c99ed860
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
5 changed files with 125 additions and 7 deletions

View file

@ -353,7 +353,11 @@ import type { DateRange, ProjectSummary } from './types.js'
// v73: cursor-agent skips agent transcripts of Cursor IDE chats, which the
// cursor provider already counts from the IDE database. Those calls leave
// cursor-agent, so it joins PENDING_REDERIVE_PROVIDER_VERSIONS at 73.
export const DAILY_CACHE_VERSION = 73
// v74: Antigravity sessions whose gen_metadata lacks usage.model are parsed
// instead of dropped, Gemini 3.8 Flash placeholders get their own ids and
// Gemini 3 Flash -a/-d rows are priced. Calls and cost only rise, so no
// PENDING_REDERIVE_PROVIDER_VERSIONS entry is needed.
export const DAILY_CACHE_VERSION = 74
const MIN_SUPPORTED_VERSION = 28
/// Providers whose per-day CALL COUNT means something different at

View file

@ -1623,6 +1623,7 @@ const SHORT_NAMES: Record<string, string> = {
'gpt-5-nano': 'GPT-5 Nano',
'gpt-5-mini': 'GPT-5 Mini',
'gpt-5': 'GPT-5',
'gemini-3.8-flash': 'Gemini 3.8 Flash',
'gemini-3.5-flash': 'Gemini 3.5 Flash',
'gemini-3.1-pro-preview': 'Gemini 3.1 Pro',
'gemini-3-flash-preview': 'Gemini 3 Flash',

View file

@ -50,7 +50,7 @@ function conversationRoots(): readonly AntigravityConversationRoot[] {
},
]
}
const CACHE_VERSION = 8
const CACHE_VERSION = 9
export const ANTIGRAVITY_CACHE_VERSION = CACHE_VERSION
export const ANTIGRAVITY_LEGACY_CACHE_FILE = 'antigravity-results.json'
export function antigravityCacheFileName(version = CACHE_VERSION): string {
@ -320,7 +320,8 @@ function parseAntigravityServerCandidates(lines: string[]): ServerCandidate[] {
// resolved at all (see antigravitySqliteModel).
const MODEL_PLACEHOLDER_PATTERN = /^MODEL_PLACEHOLDER_/
function dropPlaceholderModelId(model: string): string {
export function dropPlaceholderModelId(model: string | undefined): string {
if (!model) return 'unknown'
return MODEL_PLACEHOLDER_PATTERN.test(model) ? 'unknown' : model
}
@ -684,9 +685,12 @@ async function getModelMap(server: ServerInfo): Promise<ModelMap> {
// Strip Antigravity-specific suffixes so the pricing DB can match
const PRICING_ALIASES: Record<string, string> = {
'gemini-pro': 'gemini-3.1-pro',
'gemini-3-flash-a': 'gemini-3-flash-preview',
'gemini-3-flash-d': 'gemini-3-flash-preview',
}
function normalizePricingModel(model: string): string {
export function normalizePricingModel(model: string | undefined): string {
if (!model) return 'unknown'
const stripped = model.replace(/-(high|medium|low|agent)$/, '')
return PRICING_ALIASES[stripped] ?? stripped
}
@ -819,6 +823,9 @@ const PLACEHOLDER_MODELS: Record<string, string> = {
MODEL_PLACEHOLDER_M36: 'gemini-3.1-pro-low',
MODEL_PLACEHOLDER_M84: 'gemini-3.5-flash-high',
MODEL_PLACEHOLDER_M18: 'gemini-3-flash',
MODEL_PLACEHOLDER_M318: 'gemini-3.8-flash-high',
MODEL_PLACEHOLDER_M319: 'gemini-3.8-flash-medium',
MODEL_PLACEHOLDER_M320: 'gemini-3.8-flash-low',
MODEL_PLACEHOLDER_M35: 'claude-sonnet-4-6',
MODEL_PLACEHOLDER_M26: 'claude-opus-4-6-thinking',
}
@ -1185,7 +1192,7 @@ export function antigravityCascadeIdFromPath(path: string): string {
return basename(path).replace(/\.(pb|db)$/i, '')
}
function buildCallsFromGeneratorMetadata(
export function buildCallsFromGeneratorMetadata(
cascadeId: string,
metadata: GeneratorMetadata[],
modelMap: ModelMap,
@ -1209,7 +1216,8 @@ function buildCallsFromGeneratorMetadata(
const responseId = usage.responseId || String(i)
const dedupKey = `antigravity:${cascadeId}:${responseId}`
const model = dropPlaceholderModelId(modelMap[usage.model] ?? usage.model)
const rawModel = usage.model || entry.chatModel?.model || ''
const model = dropPlaceholderModelId(modelMap[rawModel] ?? rawModel)
const pricingModel = normalizePricingModel(model)
const timestamp = entry.chatModel?.chatStartMetadata?.createdAt ?? ''
const costUSD = calculateCost(pricingModel, inputTokens, responseTokens + thinkingTokens, cacheWriteTokens, cacheReadTokens, 0, 'standard', 0, 'antigravity')
@ -1739,6 +1747,10 @@ const modelDisplayNames: Record<string, string> = {
'Gemini 3.5 Flash (High)': 'Gemini 3.5 Flash',
'Gemini 3.5 Flash (Medium)': 'Gemini 3.5 Flash',
'Gemini 3.5 Flash (Low)': 'Gemini 3.5 Flash',
'gemini-3.8-flash': 'Gemini 3.8 Flash',
'gemini-3.8-flash-high': 'Gemini 3.8 Flash',
'gemini-3.8-flash-medium': 'Gemini 3.8 Flash',
'gemini-3.8-flash-low': 'Gemini 3.8 Flash',
'gemini-3.1-flash-image': 'Gemini 3.1 Flash',
'gemini-3.1-flash-lite': 'Gemini 3.1 Flash Lite',
'claude-opus-4-6-thinking': 'Opus 4.6',

View file

@ -614,7 +614,10 @@ export const PROVIDER_PARSE_VERSIONS: Record<string, string> = {
// cache-read-v1-est-cost: gen_metadata and RPC usage now carry cache-read
// tokens, fields 9/10 read as thinking/response (they were swapped), and
// placeholder-only models are priced and flagged costIsEstimated.
antigravity: 'worktree-project-grouping-v7-cache-read-v1-est-cost',
// model-fallback-v1: gen_metadata without usage.model falls back to
// chatModel.model instead of dropping the session, Gemini 3.8 Flash
// placeholders resolve, and Gemini 3 Flash -a/-d rows are priced.
antigravity: 'worktree-project-grouping-v7-cache-read-v1-est-cost-model-fallback-v1',
// pr-attribution-v1: the parser now reads the `message`/`part` tables for
// per-turn user prompt text and the GitHub PR URLs it references. Cached
// ZCode sessions hold empty userMessage turns and no session prLinks, so

View file

@ -21,6 +21,9 @@ import {
normalizeAntigravityToolCall,
antigravityCacheFileName,
flushAntigravityCache,
dropPlaceholderModelId,
normalizePricingModel,
buildCallsFromGeneratorMetadata,
} from '../../src/providers/antigravity.js'
import type { ParsedProviderCall } from '../../src/providers/types.js'
import { classifyTurn } from '../../src/classifier.js'
@ -677,6 +680,44 @@ describe('antigravity provider helpers', () => {
})
})
it('resolves the Gemini 3.8 Flash placeholders from standalone app gen_metadata', async () => {
if (!isSqliteAvailable()) return
await withTempAntigravityHome('codeburn-antigravity-38-flash-', async (tempHome) => {
const fixture = JSON.parse(await readFile(
new URL('../fixtures/antigravity-standalone/gen-metadata.json', import.meta.url),
'utf-8',
)) as CurrentCliFixture
const conversationsDir = join(tempHome, '.gemini', 'antigravity', 'conversations')
await mkdir(conversationsDir, { recursive: true })
// Swap row 0's model_enum M16 for a three-digit enum; the chatModel and pair lengths grow by one byte.
const withEnum = (enumNumber: string) => fixture.rows[0]!.hex
.replace('0a8103', '0a8203')
.replace(
'a201230a0a6d6f64656c5f656e756d12154d4f44454c5f504c414345484f4c4445525f4d3136',
'a201240a0a6d6f64656c5f656e756d12164d4f44454c5f504c414345484f4c4445525f4d' + Buffer.from(enumNumber).toString('hex'),
)
for (const [enumNumber, model] of [['318', 'gemini-3.8-flash-high'], ['319', 'gemini-3.8-flash-medium'], ['320', 'gemini-3.8-flash-low']]) {
const dbPath = join(conversationsDir, `fixture-m${enumNumber}.db`)
createCurrentAntigravityCliDb(dbPath, { conversationId: `fixture-m${enumNumber}`, rows: [{ idx: 0, hex: withEnum(enumNumber!) }] })
const calls = await collectAntigravityCalls({ path: dbPath, project: 'antigravity', provider: 'antigravity' })
expect(calls).toHaveLength(1)
const call = calls[0]!
expect(call.model).toBe(model)
expect(call.costIsEstimated).toBe(true)
expect(createAntigravityProvider().modelDisplayName(call.model)).toBe('Gemini 3.8 Flash')
// gemini-3.8-flash: $0.75/M input, $3.75/M output (thinking included), $0.075/M cache read.
expect(call.inputTokens).toBeGreaterThan(0)
expect(call.costUSD).toBeCloseTo(
call.inputTokens * 0.75e-6 + (call.outputTokens + call.reasoningTokens) * 3.75e-6 + call.cacheReadInputTokens * 0.075e-6,
12,
)
}
})
})
it('dates standalone rows without created_at from their first step', async () => {
if (!isSqliteAvailable()) return
@ -758,6 +799,63 @@ describe('antigravity provider helpers', () => {
})
})
it('safely drops placeholder model IDs and falls back to unknown on empty or undefined inputs', () => {
expect(dropPlaceholderModelId(undefined)).toBe('unknown')
expect(dropPlaceholderModelId('')).toBe('unknown')
expect(dropPlaceholderModelId('MODEL_PLACEHOLDER_M16')).toBe('unknown')
expect(dropPlaceholderModelId('MODEL_PLACEHOLDER_UNKNOWN')).toBe('unknown')
expect(dropPlaceholderModelId('gemini-3.1-pro-high')).toBe('gemini-3.1-pro-high')
})
it('normalizes pricing models defensively, mapping truncated suffixes and pricing aliases', () => {
expect(normalizePricingModel(undefined)).toBe('unknown')
expect(normalizePricingModel('')).toBe('unknown')
expect(normalizePricingModel('gemini-pro')).toBe('gemini-3.1-pro')
expect(normalizePricingModel('gemini-pro-agent')).toBe('gemini-3.1-pro')
expect(normalizePricingModel('gemini-3-flash-a')).toBe('gemini-3-flash-preview')
expect(normalizePricingModel('gemini-3-flash-d')).toBe('gemini-3-flash-preview')
expect(normalizePricingModel('gemini-3.8-flash-high')).toBe('gemini-3.8-flash')
expect(normalizePricingModel('gemini-3.8-flash-low')).toBe('gemini-3.8-flash')
})
it('builds calls from generator metadata with fallback to chatModel.model when usage.model is omitted', () => {
const metadata = [
{
chatModel: {
model: 'MODEL_PLACEHOLDER_M8',
chatStartMetadata: { createdAt: '2025-12-01T10:00:00.000Z' },
usage: {
// usage.model is omitted/undefined in legacy Language Server RPC
inputTokens: '150',
outputTokens: '45',
responseOutputTokens: '45',
},
},
},
{
chatModel: {
// both usage.model and chatModel.model are omitted
chatStartMetadata: { createdAt: '2025-12-01T10:05:00.000Z' },
usage: {
inputTokens: '100',
outputTokens: '20',
responseOutputTokens: '20',
},
},
},
]
const modelMap = {
MODEL_PLACEHOLDER_M8: 'gemini-pro',
}
const calls = buildCallsFromGeneratorMetadata('test-cascade', metadata, modelMap)
expect(calls).toHaveLength(2)
expect(calls[0]!.model).toBe('gemini-pro')
expect(calls[0]!.costUSD).toBeGreaterThan(0)
expect(calls[1]!.model).toBe('unknown')
})
async function withTempAntigravityHome(prefix: string, fn: (tempHome: string) => Promise<void>): Promise<void> {
const tempHome = await mkdtemp(join(tmpdir(), prefix))
const previousCacheDir = process.env['CODEBURN_CACHE_DIR']