mirror of
https://github.com/google-gemini/gemini-cli.git
synced 2026-05-13 21:32:56 -07:00
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:
@@ -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({
|
||||||
|
|||||||
@@ -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);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user