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

This commit is contained in:
Gal Zahavi
2026-05-13 14:46:41 -07:00
committed by GitHub
parent 1814c7f358
commit 77078b3e8a
9 changed files with 50 additions and 28 deletions
+9 -1
View File
@@ -20,6 +20,8 @@ import {
applyAvailabilityTransition,
} from '../availability/policyHelpers.js';
import { isPreviewModel } from '../config/models.js';
export const UPGRADE_URL_PAGE = 'https://goo.gle/set-up-gemini-code-assist';
export async function handleFallback(
@@ -28,13 +30,19 @@ export async function handleFallback(
authType?: string,
error?: unknown,
): Promise<string | boolean | null> {
const failureKind = classifyFailureKind(error);
// If a preview model is not found, record that the user lacks preview access.
if (failureKind === 'not_found' && isPreviewModel(failedModel, config)) {
config.setHasAccessToPreviewModel?.(false);
}
const chain = resolvePolicyChain(config);
const { failedPolicy, candidates } = buildFallbackPolicyContext(
chain,
failedModel,
);
const failureKind = classifyFailureKind(error);
const availability = config.getModelAvailabilityService();
const getAvailabilityContext = () => {
if (!failedPolicy) return undefined;