@@ -1240,11 +1240,22 @@ function catalogHintsFromModelsApiItem(providerName: string, item: ProviderModel
12401240async function fetchProviderModels ( name : string , prov : OcxProviderConfig , ttlMs : number , contextCap ?: number ) : Promise < CatalogModel [ ] > {
12411241 if ( prov . authMode === "forward" ) return [ ] ; // ChatGPT backend has no /models
12421242 const apiKey = await resolveModelsAuthToken ( name , prov ) ;
1243- const configured : CatalogModel [ ] = ( prov . models ?? [ ] ) . map ( id => ( {
1243+ const seedVertexDefault = prov . adapter === "google"
1244+ && prov . googleMode === "vertex"
1245+ && ( prov . models ?. length ?? 0 ) === 0
1246+ && Boolean ( prov . defaultModel ) ;
1247+ const configuredIds = seedVertexDefault && prov . defaultModel ? [ prov . defaultModel ] : ( prov . models ?? [ ] ) ;
1248+ const configured : CatalogModel [ ] = configuredIds . map ( id => ( {
12441249 id,
12451250 provider : name ,
12461251 ...catalogHintsFromProviderConfig ( name , prov , id , contextCap ) ,
12471252 } ) ) ;
1253+ const vertexDefaultSeed = seedVertexDefault ? configured [ 0 ] : undefined ;
1254+ const withVertexDefaultSeed = ( models : CatalogModel [ ] ) : CatalogModel [ ] => (
1255+ vertexDefaultSeed && ! models . some ( model => model . id === vertexDefaultSeed . id )
1256+ ? [ ...models , vertexDefaultSeed ]
1257+ : models
1258+ ) ;
12481259 if ( prov . adapter === "cursor" ) {
12491260 if ( prov . liveModels === false || ! apiKey ) return configured ;
12501261 // Cursor uses a bespoke GetUsableModels RPC (not /models), returning the full effort-suffixed
@@ -1276,12 +1287,12 @@ async function fetchProviderModels(name: string, prov: OcxProviderConfig, ttlMs:
12761287 return configured ;
12771288 }
12781289 const fresh = getFreshCached ( name , ttlMs ) ;
1279- if ( fresh ) return applyConfigHintsToCachedModels ( name , prov , fresh , contextCap ) ; // dedups Codex's frequent /v1/models polling within the TTL
1290+ if ( fresh ) return withVertexDefaultSeed ( applyConfigHintsToCachedModels ( name , prov , fresh , contextCap ) ) ; // dedups Codex's frequent /v1/models polling within the TTL
12801291 if ( isModelsFetchCoolingDown ( name ) ) {
12811292 // A recently-failed provider (unreachable API, missing proxy, bad key) must not re-pay the
12821293 // fetch timeout on every catalog poll — the dashboard polls this path per page load.
12831294 const stale = getStaleCached ( name ) ;
1284- return stale ? applyConfigHintsToCachedModels ( name , prov , stale , contextCap ) : configured ;
1295+ return stale ? withVertexDefaultSeed ( applyConfigHintsToCachedModels ( name , prov , stale , contextCap ) ) : configured ;
12851296 }
12861297 const { url, headers } = buildModelsRequest ( prov , apiKey , name ) ;
12871298 const urlClass = new URL ( url ) . hostname . endsWith ( "aiplatform.googleapis.com" )
@@ -1296,7 +1307,7 @@ async function fetchProviderModels(name: string, prov: OcxProviderConfig, ttlMs:
12961307 console . warn (
12971308 `[opencodex] Provider model discovery for "${ name } " failed with HTTP ${ res . status } [urlClass=${ urlClass } , fallback=${ fallback } ].` ,
12981309 ) ;
1299- return stale ? applyConfigHintsToCachedModels ( name , prov , stale , contextCap ) : configured ;
1310+ return stale ? withVertexDefaultSeed ( applyConfigHintsToCachedModels ( name , prov , stale , contextCap ) ) : configured ;
13001311 }
13011312 const json = await res . json ( ) as unknown ;
13021313 const data = json !== null && typeof json === "object" && ! Array . isArray ( json )
@@ -1308,7 +1319,7 @@ async function fetchProviderModels(name: string, prov: OcxProviderConfig, ttlMs:
13081319 `[opencodex] Provider model discovery for "${ name } " returned malformed 2xx data; using stale/static catalog degradation.` ,
13091320 ) ;
13101321 const stale = getStaleCached ( name ) ;
1311- return stale ? applyConfigHintsToCachedModels ( name , prov , stale , contextCap ) : configured ;
1322+ return stale ? withVertexDefaultSeed ( applyConfigHintsToCachedModels ( name , prov , stale , contextCap ) ) : configured ;
13121323 }
13131324 const items = data ;
13141325 const live = items . map ( m => applyProviderConfigHints ( name , prov , {
@@ -1331,7 +1342,7 @@ async function fetchProviderModels(name: string, prov: OcxProviderConfig, ttlMs:
13311342 if ( dated ) {
13321343 // Reapply config hints so alias-keyed overrides (modelContextWindows etc.) win.
13331344 live . push ( applyProviderConfigHints ( name , prov , { ...dated , id : m . id } , contextCap ) ) ;
1334- } else if ( shouldRetainConfiguredProviderModel ( name , m . id ) ) {
1345+ } else if ( seedVertexDefault || shouldRetainConfiguredProviderModel ( name , m . id ) ) {
13351346 live . push ( m ) ;
13361347 } else {
13371348 droppedConfiguredIds . push ( m . id ) ;
@@ -1355,7 +1366,7 @@ async function fetchProviderModels(name: string, prov: OcxProviderConfig, ttlMs:
13551366 console . warn (
13561367 `[opencodex] Provider model discovery for "${ name } " threw ${ error instanceof Error ? error . name : "unknown" } [urlClass=${ urlClass } , fallback=${ fallback } ].` ,
13571368 ) ;
1358- return stale ? applyConfigHintsToCachedModels ( name , prov , stale , contextCap ) : configured ;
1369+ return stale ? withVertexDefaultSeed ( applyConfigHintsToCachedModels ( name , prov , stale , contextCap ) ) : configured ;
13591370 }
13601371}
13611372
0 commit comments