mirror of
https://github.com/google-gemini/gemini-cli.git
synced 2026-03-13 23:51:16 -07:00
Revert "feat(core): Fix bug with incorrect model overriding." (#13483)
This commit is contained in:
@@ -152,7 +152,7 @@ describe('ModelRouterService', () => {
|
|||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should NOT upgrade to Preview Model when preview features are enabled and model is 2.5 Pro', async () => {
|
it('should upgrade to Preview Model when preview features are enabled and model is 2.5 Pro', async () => {
|
||||||
vi.spyOn(mockCompositeStrategy, 'route').mockResolvedValue({
|
vi.spyOn(mockCompositeStrategy, 'route').mockResolvedValue({
|
||||||
model: DEFAULT_GEMINI_MODEL,
|
model: DEFAULT_GEMINI_MODEL,
|
||||||
metadata: { source: 'test', latencyMs: 0, reasoning: 'test' },
|
metadata: { source: 'test', latencyMs: 0, reasoning: 'test' },
|
||||||
@@ -162,7 +162,7 @@ describe('ModelRouterService', () => {
|
|||||||
|
|
||||||
const decision = await service.route(mockContext);
|
const decision = await service.route(mockContext);
|
||||||
|
|
||||||
expect(decision.model).toBe(DEFAULT_GEMINI_MODEL);
|
expect(decision.model).toBe(PREVIEW_GEMINI_MODEL);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should NOT upgrade to Preview Model when preview features are disabled', async () => {
|
it('should NOT upgrade to Preview Model when preview features are disabled', async () => {
|
||||||
@@ -215,7 +215,7 @@ describe('ModelRouterService', () => {
|
|||||||
expect(decision.model).toBe(DEFAULT_GEMINI_MODEL);
|
expect(decision.model).toBe(DEFAULT_GEMINI_MODEL);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should NOT upgrade to Preview Model even if fallback mode is active (probing behavior)', async () => {
|
it('should upgrade to Preview Model even if fallback mode is active (probing behavior)', async () => {
|
||||||
vi.spyOn(mockCompositeStrategy, 'route').mockResolvedValue({
|
vi.spyOn(mockCompositeStrategy, 'route').mockResolvedValue({
|
||||||
model: DEFAULT_GEMINI_MODEL,
|
model: DEFAULT_GEMINI_MODEL,
|
||||||
metadata: { source: 'default', latencyMs: 0, reasoning: 'Default' },
|
metadata: { source: 'default', latencyMs: 0, reasoning: 'Default' },
|
||||||
@@ -225,7 +225,7 @@ describe('ModelRouterService', () => {
|
|||||||
|
|
||||||
const decision = await service.route(mockContext);
|
const decision = await service.route(mockContext);
|
||||||
|
|
||||||
expect(decision.model).toBe(DEFAULT_GEMINI_MODEL);
|
expect(decision.model).toBe(PREVIEW_GEMINI_MODEL);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -5,6 +5,10 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
import type { Config } from '../config/config.js';
|
import type { Config } from '../config/config.js';
|
||||||
|
import {
|
||||||
|
PREVIEW_GEMINI_MODEL,
|
||||||
|
DEFAULT_GEMINI_MODEL,
|
||||||
|
} from '../config/models.js';
|
||||||
import type {
|
import type {
|
||||||
RoutingContext,
|
RoutingContext,
|
||||||
RoutingDecision,
|
RoutingDecision,
|
||||||
@@ -62,6 +66,23 @@ export class ModelRouterService {
|
|||||||
this.config.getBaseLlmClient(),
|
this.config.getBaseLlmClient(),
|
||||||
);
|
);
|
||||||
|
|
||||||
|
// Unified Preview Model Logic:
|
||||||
|
// If the decision is to use 'gemini-2.5-pro' and preview features are enabled,
|
||||||
|
// we attempt to upgrade to 'gemini-3.0-pro' (Preview Model).
|
||||||
|
if (
|
||||||
|
decision.model === DEFAULT_GEMINI_MODEL &&
|
||||||
|
this.config.getPreviewFeatures() &&
|
||||||
|
!decision.metadata.source.includes('override')
|
||||||
|
) {
|
||||||
|
// We ALWAYS attempt to upgrade to Preview Model here.
|
||||||
|
// If we are in fallback mode, the 'previewModelBypassMode' flag (handled in handler.ts/geminiChat.ts)
|
||||||
|
// will ensure we downgrade to 2.5 Pro for the actual API call if needed.
|
||||||
|
// This allows us to "probe" Preview Model periodically (i.e., every new request tries Preview Model first).
|
||||||
|
decision.model = PREVIEW_GEMINI_MODEL;
|
||||||
|
decision.metadata.source += ' (Preview Model)';
|
||||||
|
decision.metadata.reasoning += ' (Upgraded to Preview Model)';
|
||||||
|
}
|
||||||
|
|
||||||
const event = new ModelRoutingEvent(
|
const event = new ModelRoutingEvent(
|
||||||
decision.model,
|
decision.model,
|
||||||
decision.metadata.source,
|
decision.metadata.source,
|
||||||
|
|||||||
Reference in New Issue
Block a user