@@ -11,9 +11,27 @@ import { isValidModelDiscoveryModelId, MODEL_DISCOVERY_MAX_MODELS } from "./mode
1111
1212// ── Wire IDs (what CCA :fetchAvailableModels returns) ──
1313
14- /** Current Antigravity Flash generation. */
14+ /**
15+ * Current Antigravity Flash generation: tier → the wire id that actually exists.
16+ *
17+ * Proven against the live backend: the CCA envelope 404s on the bare id
18+ * `gemini-3.7-flash` and on `thinkingConfig` tiers riding that bare id — only the
19+ * SUFFIXED wire ids (`gemini-3.7-flash-low/-medium/-high`) are real entities.
20+ * Every request must therefore land on a suffixed id; the bare id stays the
21+ * picker identity that the resolver maps to the current default tier.
22+ */
23+ const ANTIGRAVITY_FLASH_WIRE_TIERS : Record < string , string > = {
24+ low : "gemini-3.7-flash-low" ,
25+ medium : "gemini-3.7-flash-medium" ,
26+ high : "gemini-3.7-flash-high" ,
27+ } ;
28+
29+ /** Picker identity of the current Flash generation (a collapsed base, not a wire id). */
1530const GEMINI_FLASH_CURRENT = "gemini-3.7-flash" ;
1631
32+ /** Default tier for the bare 3.7 picker id — matches the previous generation's default. */
33+ const ANTIGRAVITY_FLASH_DEFAULT_TIER = "medium" ;
34+
1735/**
1836 * Retired Flash ids → the reasoning tier they used to encode.
1937 *
@@ -23,9 +41,6 @@ const GEMINI_FLASH_CURRENT = "gemini-3.7-flash";
2341 * alias as "the suffix IS the effort" and deliberately sends no thinkingConfig, so
2442 * `gemini-3.6-flash-high` would silently become an untiered 3.7 call. Carrying the
2543 * level here preserves what the user actually chose.
26- *
27- * 3.7 exposes tiers through `thinkingLevel` on ONE wire id rather than through
28- * suffixed wire ids, which is why the mapping is id → level and not id → id.
2944 */
3045const RETIRED_FLASH_TIERS : Record < string , string > = {
3146 // 3.6 generation.
@@ -42,7 +57,9 @@ const RETIRED_FLASH_TIERS: Record<string, string> = {
4257} ;
4358
4459const ANTIGRAVITY_WIRE_MODELS = [
45- "gemini-3.7-flash" ,
60+ "gemini-3.7-flash-low" ,
61+ "gemini-3.7-flash-medium" ,
62+ "gemini-3.7-flash-high" ,
4663 "gemini-3.1-pro-low" ,
4764 "gemini-pro-agent" ,
4865 "gemini-3.1-flash-image" ,
@@ -110,6 +127,7 @@ export const ANTIGRAVITY_MODEL_EFFORTS: Record<string, string[]> = {
110127
111128// ── Effort → wire model map for Gemini base models ──
112129const ANTIGRAVITY_EFFORT_WIRE_MAP : Record < string , Record < string , string > > = {
130+ "gemini-3.7-flash" : ANTIGRAVITY_FLASH_WIRE_TIERS ,
113131 "gemini-3.1-pro" : {
114132 low : "gemini-3.1-pro-low" ,
115133 high : "gemini-pro-agent" ,
@@ -118,17 +136,10 @@ const ANTIGRAVITY_EFFORT_WIRE_MAP: Record<string, Record<string, string>> = {
118136
119137// ── Default effort per Gemini base model ──
120138const ANTIGRAVITY_DEFAULT_EFFORT : Record < string , string > = {
139+ "gemini-3.7-flash" : ANTIGRAVITY_FLASH_DEFAULT_TIER ,
121140 "gemini-3.1-pro" : "high" ,
122141} ;
123142
124- /**
125- * Gemini base models whose efforts ride on `thinkingLevel` against a single wire id
126- * instead of suffixed wire ids, with the level applied when the caller names none.
127- */
128- const ANTIGRAVITY_THINKING_LEVEL_MODELS : Record < string , string > = {
129- "gemini-3.7-flash" : "medium" ,
130- } ;
131-
132143// `minimal` is deliberately absent: Google documents it as unsupported for the current
133144// Flash generation, where it is an error rather than a quieter tier.
134145const ANTIGRAVITY_THINKING_LEVELS = new Set ( [ "low" , "medium" , "high" ] ) ;
@@ -150,6 +161,9 @@ const ANTIGRAVITY_VISIBLE_MODEL_ALIASES: Record<string, string> = {
150161const ANTIGRAVITY_COMPATIBILITY_MODEL_ALIASES : Record < string , string > = {
151162 "gemini-3.1-pro-low" : "gemini-3.1-pro-low" ,
152163 "gemini-pro-agent" : "gemini-pro-agent" ,
164+ // 3.7 Flash wire tiers are real upstream entities: identity aliases so a saved
165+ // selection with an explicit suffix keeps routing to that exact tier.
166+ ...ANTIGRAVITY_FLASH_WIRE_TIERS ,
153167 // ── Retired Flash generations ──
154168 // Google takes the previous Antigravity Flash model offline almost immediately
155169 // once its successor ships, so 3.6 (and the 3.5 ids that used to land on it)
@@ -182,7 +196,9 @@ function isKnownAntigravityPickerModelId(value: string): boolean {
182196
183197// Context windows from the upstream `:fetchAvailableModels` maxTokens per model.
184198const ANTIGRAVITY_WIRE_MODEL_CONTEXT_WINDOWS : Record < string , number > = {
185- "gemini-3.7-flash" : 1_048_576 ,
199+ "gemini-3.7-flash-low" : 1_048_576 ,
200+ "gemini-3.7-flash-medium" : 1_048_576 ,
201+ "gemini-3.7-flash-high" : 1_048_576 ,
186202 "gemini-3.1-pro-low" : 1_048_576 ,
187203 "gemini-pro-agent" : 1_048_576 ,
188204 "gemini-3.1-flash-image" : 1_048_576 ,
@@ -341,6 +357,7 @@ export function retiredAntigravityFlashTier(modelId: string): string | undefined
341357 * Resolve a picker-visible base model + optional reasoning effort to the CCA wire model ID.
342358 *
343359 * Precedence (evaluated in order):
360+ * 0. Retired Flash id → current Flash wire id + thinkingLevel carrying the retired tier.
344361 * 1. Suffix wire ID or compat alias → resolve via `resolveAntigravityWireModelId`, no thinkingConfig.
345362 * 2. Mapped Gemini base with effort → return mapped wire ID + thinkingLevel.
346363 * 3. Mapped Gemini base without effort → return default-effort wire ID, no thinkingConfig.
@@ -356,32 +373,27 @@ export function resolveAntigravityEffortWireModel(
356373 // suffix check because those ids are aliases, and rule 1 would drop the tier.
357374 const retiredTier = retiredAntigravityFlashTier ( modelId ) ;
358375 if ( retiredTier ) {
359- return {
360- wireModelId : GEMINI_FLASH_CURRENT ,
361- thinkingLevel : effort ? resolveAntigravityThinkingLevel ( effort ) ?? retiredTier : retiredTier ,
362- } ;
376+ const level = effort ? resolveAntigravityThinkingLevel ( effort ) ?? retiredTier : retiredTier ;
377+ return { wireModelId : ANTIGRAVITY_FLASH_WIRE_TIERS [ level ] ! , thinkingLevel : level } ;
363378 }
364379
365- // Rule 1: suffix/compat alias — suffix IS the effort.
380+ // Rule 1: suffix/compat alias — suffix IS the effort. 3.7 Flash wire tiers land here
381+ // (identity aliases) and must NOT carry thinkingConfig: the suffix already IS the tier,
382+ // and sending both on the same suffixed id is a contradictory request.
366383 if ( isAntigravitySuffixModelId ( modelId ) ) {
367384 return { wireModelId : resolveAntigravityWireModelId ( modelId ) } ;
368385 }
369386
370- // Rule 1b: single-wire-id Gemini model whose tiers ride on thinkingLevel. Without
371- // this the model falls to rule 5 and silently loses reasoning control entirely.
372- const defaultLevel = ANTIGRAVITY_THINKING_LEVEL_MODELS [ modelId ] ;
373- if ( defaultLevel ) {
374- return {
375- wireModelId : modelId ,
376- thinkingLevel : effort ? resolveAntigravityThinkingLevel ( effort ) ?? defaultLevel : defaultLevel ,
377- } ;
378- }
379-
380- // Rule 2/3: mapped Gemini base model.
387+ // Rule 2/3: mapped Gemini base model. Non-enum efforts clamp through the same
388+ // thinking-level sanitizer first ("max" → high), so an out-of-ladder value can
389+ // never silently degrade to the default tier.
381390 const effortMap = ANTIGRAVITY_EFFORT_WIRE_MAP [ modelId ] ;
382391 if ( effortMap ) {
383- if ( effort && effort in effortMap ) {
384- return { wireModelId : effortMap [ effort ] ! , thinkingLevel : effort } ;
392+ if ( effort ) {
393+ const level = resolveAntigravityThinkingLevel ( effort ) ;
394+ if ( level && level in effortMap ) {
395+ return { wireModelId : effortMap [ level ] ! , thinkingLevel : level } ;
396+ }
385397 }
386398 const defaultEffort = ANTIGRAVITY_DEFAULT_EFFORT [ modelId ] ! ;
387399 return { wireModelId : effortMap [ defaultEffort ] ! } ;
0 commit comments