fix(core): ensure stable fallback for restricted preview models

Corrects model selection failures for GCP/Google Auth users by:
1. Verifying preview access via quota instead of assuming true for GCP.
2. Preserving original model intent in policyHelpers to ensure correct
   downgrade to the Gemini 2.5 stable chain.
This commit is contained in:
galz10
2026-05-13 10:24:16 -07:00
parent 8cda688fe2
commit a2f4f7ff85
2 changed files with 8 additions and 8 deletions
@@ -57,6 +57,9 @@ export function resolvePolicyChain(
const useCustomToolModel = config.getUseCustomToolModelSync?.() ?? false; const useCustomToolModel = config.getUseCustomToolModelSync?.() ?? false;
const hasAccessToPreview = config.getHasAccessToPreviewModel?.() ?? true; const hasAccessToPreview = config.getHasAccessToPreviewModel?.() ?? true;
// Capture the original family intent before any normalization or early downgrade.
const isOriginallyGemini3 = isGemini3Model(modelFromConfig, config);
const resolvedModel = normalizeModelId( const resolvedModel = normalizeModelId(
resolveModel( resolveModel(
modelFromConfig, modelFromConfig,
@@ -78,7 +81,7 @@ export function resolvePolicyChain(
wrapsAround || wrapsAround ||
isAutoPreferred || isAutoPreferred ||
isAutoConfigured || isAutoConfigured ||
isGemini3Model(resolvedModel, config); isOriginallyGemini3;
// --- DYNAMIC PATH --- // --- DYNAMIC PATH ---
if (config.getExperimentalDynamicModelConfiguration?.() === true) { if (config.getExperimentalDynamicModelConfiguration?.() === true) {
@@ -91,7 +94,7 @@ export function resolvePolicyChain(
if (resolvedModel === DEFAULT_GEMINI_FLASH_LITE_MODEL) { if (resolvedModel === DEFAULT_GEMINI_FLASH_LITE_MODEL) {
chain = config.modelConfigService.resolveChain('lite', context); chain = config.modelConfigService.resolveChain('lite', context);
} else if ( } else if (
isGemini3Model(normalizeModelId(resolvedModel), config) || isOriginallyGemini3 ||
isAutoPreferred || isAutoPreferred ||
isAutoConfigured isAutoConfigured
) { ) {
@@ -132,14 +135,14 @@ export function resolvePolicyChain(
if (resolvedModel === DEFAULT_GEMINI_FLASH_LITE_MODEL) { if (resolvedModel === DEFAULT_GEMINI_FLASH_LITE_MODEL) {
chain = getFlashLitePolicyChain(); chain = getFlashLitePolicyChain();
} else if ( } else if (
isGemini3Model(resolvedModel, config) || isOriginallyGemini3 ||
isAutoPreferred || isAutoPreferred ||
isAutoConfigured isAutoConfigured
) { ) {
const isAutoSelection = isAutoPreferred || isAutoConfigured; const isAutoSelection = isAutoPreferred || isAutoConfigured;
if (hasAccessToPreview) { if (hasAccessToPreview) {
const previewEnabled = const previewEnabled =
isGemini3Model(resolvedModel, config) || isOriginallyGemini3 ||
normalizedPreferredModel === PREVIEW_GEMINI_MODEL_AUTO || normalizedPreferredModel === PREVIEW_GEMINI_MODEL_AUTO ||
configuredModel === PREVIEW_GEMINI_MODEL_AUTO; configuredModel === PREVIEW_GEMINI_MODEL_AUTO;
chain = getModelPolicyChain({ chain = getModelPolicyChain({
+1 -4
View File
@@ -1630,10 +1630,7 @@ export class Config implements McpContext, AgentLoopContext {
this.baseLlmClient = new BaseLlmClient(this.contentGenerator, this); this.baseLlmClient = new BaseLlmClient(this.contentGenerator, this);
const authType = this.contentGeneratorConfig.authType; const authType = this.contentGeneratorConfig.authType;
if ( if (authType === AuthType.USE_GEMINI) {
authType === AuthType.USE_GEMINI ||
authType === AuthType.USE_VERTEX_AI
) {
this.setHasAccessToPreviewModel(true); this.setHasAccessToPreviewModel(true);
} }