Respect backend definitions for 3.5 flash and Update auto mode to use 3.5 flash when the flag is enabled. (#27645)

This commit is contained in:
David Pierce
2026-06-03 15:12:53 +00:00
committed by GitHub
parent d2cd12a7cb
commit e4315b36eb
24 changed files with 463 additions and 42 deletions
@@ -242,4 +242,22 @@ describe('ApprovalModeStrategy', () => {
// Should resolve to Preview Flash (3.0) because resolveClassifierModel uses preview variants for Gemini 3
expect(decision?.model).toBe(PREVIEW_GEMINI_FLASH_MODEL);
});
it('should route to DEFAULT_GEMINI_FLASH_MODEL when hasGemini35FlashGAAccess is true and plan is approved', async () => {
vi.mocked(mockConfig.getModel).mockReturnValue(GEMINI_MODEL_ALIAS_AUTO);
mockConfig.hasGemini35FlashGAAccess = vi.fn().mockReturnValue(true);
vi.mocked(mockConfig.getApprovalMode).mockReturnValue(ApprovalMode.DEFAULT);
vi.mocked(mockConfig.getApprovedPlanPath).mockReturnValue(
'/path/to/plan.md',
);
const decision = await strategy.route(
mockContext,
mockConfig,
mockBaseLlmClient,
);
expect(decision?.model).toBe(DEFAULT_GEMINI_FLASH_MODEL);
});
});
@@ -54,6 +54,7 @@ export class ApprovalModeStrategy implements RoutingStrategy {
config.getUseCustomToolModel(),
config.getHasAccessToPreviewModel(),
]);
const useGemini3_5Flash = config.hasGemini35FlashGAAccess?.() ?? false;
// 1. Planning Phase: If ApprovalMode === PLAN, explicitly route to the Pro model.
if (approvalMode === ApprovalMode.PLAN) {
@@ -64,6 +65,7 @@ export class ApprovalModeStrategy implements RoutingStrategy {
useCustomToolModel,
hasAccessToPreview,
config,
useGemini3_5Flash,
);
return {
model: proModel,
@@ -82,6 +84,7 @@ export class ApprovalModeStrategy implements RoutingStrategy {
useCustomToolModel,
hasAccessToPreview,
config,
useGemini3_5Flash,
);
return {
model: flashModel,
@@ -522,5 +522,27 @@ describe('ClassifierStrategy', () => {
expect(decision?.model).toBe(PREVIEW_GEMINI_3_1_CUSTOM_TOOLS_MODEL);
});
it('should route to DEFAULT_GEMINI_FLASH_MODEL when hasGemini35FlashGAAccess is true', async () => {
mockConfig.hasGemini35FlashGAAccess = vi.fn().mockReturnValue(true);
vi.mocked(mockConfig.getModel).mockReturnValue(PREVIEW_GEMINI_MODEL_AUTO);
const mockApiResponse = {
reasoning: 'Simple task',
model_choice: 'flash',
};
vi.mocked(mockBaseLlmClient.generateJson).mockResolvedValue(
mockApiResponse,
);
const decision = await strategy.route(
mockContext,
mockConfig,
mockBaseLlmClient,
mockLocalLiteRtLmClient,
);
expect(decision?.model).toBe(DEFAULT_GEMINI_FLASH_MODEL);
});
});
});
@@ -186,6 +186,7 @@ export class ClassifierStrategy implements RoutingStrategy {
config.getGemini31Launched(),
config.getUseCustomToolModel(),
]);
const useGemini3_5Flash = config.hasGemini35FlashGAAccess?.() ?? false;
const selectedModel = normalizeModelId(
resolveClassifierModel(
normalizeModelId(model),
@@ -194,6 +195,7 @@ export class ClassifierStrategy implements RoutingStrategy {
useCustomToolModel,
config.getHasAccessToPreviewModel?.() ?? true,
config,
useGemini3_5Flash,
),
);
@@ -12,6 +12,7 @@ import type { BaseLlmClient } from '../../core/baseLlmClient.js';
import {
DEFAULT_GEMINI_FLASH_MODEL,
DEFAULT_GEMINI_MODEL,
PREVIEW_GEMINI_MODEL_AUTO,
} from '../../config/models.js';
import type { Content } from '@google/genai';
import { debugLogger } from '../../utils/debugLogger.js';
@@ -323,4 +324,24 @@ second message
expect(lastTurn!.parts!.at(0)!.text).toEqual(expectedLastTurn);
});
it('should route to DEFAULT_GEMINI_FLASH_MODEL when hasGemini35FlashGAAccess is true', async () => {
mockConfig.hasGemini35FlashGAAccess = vi.fn().mockReturnValue(true);
mockConfig.getModel = () => PREVIEW_GEMINI_MODEL_AUTO;
const mockApiResponse = {
reasoning: 'Simple task',
model_choice: 'flash',
};
mockGenerateJson.mockResolvedValue(mockApiResponse);
const decision = await strategy.route(
mockContext,
mockConfig,
mockBaseLlmClient,
mockLocalLiteRtLmClient,
);
expect(decision?.model).toBe(DEFAULT_GEMINI_FLASH_MODEL);
});
});
@@ -216,6 +216,7 @@ ${formattedHistory}
config.getUseCustomToolModel(),
config.getHasAccessToPreviewModel(),
]);
const useGemini3_5Flash = config.hasGemini35FlashGAAccess?.() ?? false;
const selectedModel = resolveClassifierModel(
context.requestedModel ?? config.getModel(),
@@ -224,6 +225,7 @@ ${formattedHistory}
useCustomToolModel,
hasAccessToPreview,
config,
useGemini3_5Flash,
);
return {
@@ -20,6 +20,7 @@ import {
PREVIEW_GEMINI_MODEL_AUTO,
DEFAULT_GEMINI_MODEL_AUTO,
DEFAULT_GEMINI_MODEL,
DEFAULT_GEMINI_FLASH_MODEL,
} from '../../config/models.js';
import { promptIdContext } from '../../utils/promptIdContext.js';
import type { Content } from '@google/genai';
@@ -894,5 +895,27 @@ describe('NumericalClassifierStrategy', () => {
expect(decision?.model).toBe(PREVIEW_GEMINI_3_1_MODEL);
});
it('should route to DEFAULT_GEMINI_FLASH_MODEL when hasGemini35FlashGAAccess is true', async () => {
mockConfig.hasGemini35FlashGAAccess = vi.fn().mockReturnValue(true);
vi.mocked(mockConfig.getModel).mockReturnValue(PREVIEW_GEMINI_MODEL_AUTO);
const mockApiResponse = {
complexity_reasoning: 'Simple task',
complexity_score: 10,
};
vi.mocked(mockBaseLlmClient.generateJson).mockResolvedValue(
mockApiResponse,
);
const decision = await strategy.route(
mockContext,
mockConfig,
mockBaseLlmClient,
mockLocalLiteRtLmClient,
);
expect(decision?.model).toBe(DEFAULT_GEMINI_FLASH_MODEL);
});
});
});
@@ -184,6 +184,7 @@ export class NumericalClassifierStrategy implements RoutingStrategy {
config.getGemini31Launched(),
config.getUseCustomToolModel(),
]);
const useGemini3_5Flash = config.hasGemini35FlashGAAccess?.() ?? false;
const selectedModel = normalizeModelId(
resolveClassifierModel(
normalizeModelId(model),
@@ -192,6 +193,7 @@ export class NumericalClassifierStrategy implements RoutingStrategy {
useCustomToolModel,
config.getHasAccessToPreviewModel?.() ?? true,
config,
useGemini3_5Flash,
),
);