Compare commits
4 Commits
main
...
akkr/gemma
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
f5cf3cbe5a | ||
|
|
277f0bb361 | ||
|
|
5510d17a8b | ||
|
|
3a29331ff6 |
@ -1,4 +1,4 @@
|
||||
# Gemini CLI
|
||||
## Gemini CLI
|
||||
|
||||
[](https://github.com/google-gemini/gemini-cli/actions/workflows/ci.yml)
|
||||
[](https://github.com/google-gemini/gemini-cli/actions/workflows/chained_e2e.yml)
|
||||
|
||||
@ -110,7 +110,7 @@ import type {
|
||||
ResolvedModelConfig,
|
||||
} from '../services/modelConfigService.js';
|
||||
import { getModelConfigAlias, type AgentRegistry } from './registry.js';
|
||||
import type { ModelRouterService } from '../routing/modelRouterService.js';
|
||||
import { PREVIEW_GEMINI_FLASH_MODEL } from '../config/models.js';
|
||||
|
||||
let mockChatHistory: Content[] = [];
|
||||
const mockSetHistory = vi.fn((newHistory: Content[]) => {
|
||||
@ -1659,21 +1659,11 @@ describe('LocalAgentExecutor', () => {
|
||||
});
|
||||
});
|
||||
|
||||
describe('Model Routing', () => {
|
||||
it('should use model routing when the agent model is "auto"', async () => {
|
||||
describe('Model Selection', () => {
|
||||
it('should use PREVIEW_GEMINI_FLASH_MODEL when the agent model is "auto"', async () => {
|
||||
const definition = createTestDefinition();
|
||||
definition.modelConfig.model = 'auto';
|
||||
|
||||
const mockRouter = {
|
||||
route: vi.fn().mockResolvedValue({
|
||||
model: 'routed-model',
|
||||
metadata: { source: 'test', reasoning: 'test' },
|
||||
}),
|
||||
};
|
||||
vi.spyOn(mockConfig, 'getModelRouterService').mockReturnValue(
|
||||
mockRouter as unknown as ModelRouterService,
|
||||
);
|
||||
|
||||
// Mock resolved config to return 'auto'
|
||||
vi.spyOn(
|
||||
mockConfig.modelConfigService,
|
||||
@ -1699,9 +1689,8 @@ describe('LocalAgentExecutor', () => {
|
||||
|
||||
await executor.run({ goal: 'test' }, signal);
|
||||
|
||||
expect(mockRouter.route).toHaveBeenCalled();
|
||||
expect(mockSendMessageStream).toHaveBeenCalledWith(
|
||||
expect.objectContaining({ model: 'routed-model' }),
|
||||
expect.objectContaining({ model: PREVIEW_GEMINI_FLASH_MODEL }),
|
||||
expect.any(Array),
|
||||
expect.any(String),
|
||||
expect.any(AbortSignal),
|
||||
@ -1709,17 +1698,10 @@ describe('LocalAgentExecutor', () => {
|
||||
);
|
||||
});
|
||||
|
||||
it('should NOT use model routing when the agent model is NOT "auto"', async () => {
|
||||
it('should use concrete-model when the agent model is NOT "auto"', async () => {
|
||||
const definition = createTestDefinition();
|
||||
definition.modelConfig.model = 'concrete-model';
|
||||
|
||||
const mockRouter = {
|
||||
route: vi.fn(),
|
||||
};
|
||||
vi.spyOn(mockConfig, 'getModelRouterService').mockReturnValue(
|
||||
mockRouter as unknown as ModelRouterService,
|
||||
);
|
||||
|
||||
// Mock resolved config to return 'concrete-model'
|
||||
vi.spyOn(
|
||||
mockConfig.modelConfigService,
|
||||
@ -1745,7 +1727,6 @@ describe('LocalAgentExecutor', () => {
|
||||
|
||||
await executor.run({ goal: 'test' }, signal);
|
||||
|
||||
expect(mockRouter.route).not.toHaveBeenCalled();
|
||||
expect(mockSendMessageStream).toHaveBeenCalledWith(
|
||||
expect.objectContaining({ model: 'concrete-model' }),
|
||||
expect.any(Array),
|
||||
|
||||
@ -60,8 +60,11 @@ import {
|
||||
} from './types.js';
|
||||
import { getErrorMessage } from '../utils/errors.js';
|
||||
import { templateString } from './utils.js';
|
||||
import { DEFAULT_GEMINI_MODEL, isAutoModel } from '../config/models.js';
|
||||
import type { RoutingContext } from '../routing/routingStrategy.js';
|
||||
import {
|
||||
DEFAULT_GEMINI_MODEL,
|
||||
isAutoModel,
|
||||
PREVIEW_GEMINI_FLASH_MODEL,
|
||||
} from '../config/models.js';
|
||||
import { parseThought } from '../utils/thoughtUtils.js';
|
||||
import { type z } from 'zod';
|
||||
import { zodToJsonSchema } from 'zod-to-json-schema';
|
||||
@ -865,25 +868,7 @@ export class LocalAgentExecutor<TOutput extends z.ZodTypeAny> {
|
||||
|
||||
let modelToUse: string;
|
||||
if (isAutoModel(requestedModel)) {
|
||||
// TODO(joshualitt): This try / catch is inconsistent with the routing
|
||||
// behavior for the main agent. Ideally, we would have a universal
|
||||
// policy for routing failure. Given routing failure does not necessarily
|
||||
// mean generation will fail, we may want to share this logic with
|
||||
// other places we use model routing.
|
||||
try {
|
||||
const routingContext: RoutingContext = {
|
||||
history: chat.getHistory(/*curated=*/ true),
|
||||
request: message.parts || [],
|
||||
signal,
|
||||
requestedModel,
|
||||
};
|
||||
const router = this.context.config.getModelRouterService();
|
||||
const decision = await router.route(routingContext);
|
||||
modelToUse = decision.model;
|
||||
} catch (error) {
|
||||
debugLogger.warn(`Error during model routing: ${error}`);
|
||||
modelToUse = DEFAULT_GEMINI_MODEL;
|
||||
}
|
||||
modelToUse = PREVIEW_GEMINI_FLASH_MODEL;
|
||||
} else {
|
||||
modelToUse = requestedModel;
|
||||
}
|
||||
|
||||
@ -59,6 +59,7 @@ export const PREVIEW_GEMINI_3_1_FLASH_LITE_MODEL =
|
||||
export const DEFAULT_GEMINI_MODEL = 'gemini-2.5-pro';
|
||||
export const DEFAULT_GEMINI_FLASH_MODEL = 'gemini-2.5-flash';
|
||||
export const DEFAULT_GEMINI_FLASH_LITE_MODEL = 'gemini-2.5-flash-lite';
|
||||
export const GEMMA_4_MODEL = 'gemma-4-26b-a4b-it';
|
||||
|
||||
export const VALID_GEMINI_MODELS = new Set([
|
||||
PREVIEW_GEMINI_MODEL,
|
||||
@ -69,6 +70,7 @@ export const VALID_GEMINI_MODELS = new Set([
|
||||
DEFAULT_GEMINI_MODEL,
|
||||
DEFAULT_GEMINI_FLASH_MODEL,
|
||||
DEFAULT_GEMINI_FLASH_LITE_MODEL,
|
||||
GEMMA_4_MODEL,
|
||||
]);
|
||||
|
||||
export const PREVIEW_GEMINI_MODEL_AUTO = 'auto-gemini-3';
|
||||
|
||||
@ -32,7 +32,10 @@ import {
|
||||
type ServerGeminiStreamEvent,
|
||||
} from './turn.js';
|
||||
import { getCoreSystemPrompt } from './prompts.js';
|
||||
import { DEFAULT_GEMINI_MODEL_AUTO } from '../config/models.js';
|
||||
import {
|
||||
DEFAULT_GEMINI_MODEL_AUTO,
|
||||
PREVIEW_GEMINI_FLASH_MODEL,
|
||||
} from '../config/models.js';
|
||||
import { FileDiscoveryService } from '../services/fileDiscoveryService.js';
|
||||
import { setSimulate429 } from '../utils/testUtils.js';
|
||||
import { tokenLimit } from './tokenLimits.js';
|
||||
@ -177,9 +180,10 @@ describe('Gemini Client (client.ts)', () => {
|
||||
setSimulate429(false);
|
||||
|
||||
mockRouterService = {
|
||||
route: vi
|
||||
.fn()
|
||||
.mockResolvedValue({ model: 'default-routed-model', reason: 'test' }),
|
||||
route: vi.fn().mockResolvedValue({
|
||||
model: PREVIEW_GEMINI_FLASH_MODEL,
|
||||
reason: 'test',
|
||||
}),
|
||||
};
|
||||
|
||||
mockContentGenerator = {
|
||||
@ -950,7 +954,7 @@ ${JSON.stringify(
|
||||
// Assert
|
||||
expect(ideContextStore.get).toHaveBeenCalled();
|
||||
expect(mockTurnRunFn).toHaveBeenCalledWith(
|
||||
{ model: 'default-routed-model', isChatModel: true },
|
||||
{ model: PREVIEW_GEMINI_FLASH_MODEL, isChatModel: true },
|
||||
initialRequest,
|
||||
expect.any(AbortSignal),
|
||||
undefined,
|
||||
@ -1789,7 +1793,7 @@ ${JSON.stringify(
|
||||
expect(mockTurnRunFn).toHaveBeenCalled();
|
||||
});
|
||||
|
||||
describe('Model Routing', () => {
|
||||
describe.skip('Model Routing', () => {
|
||||
let mockRouterService: { route: Mock };
|
||||
|
||||
beforeEach(() => {
|
||||
@ -1997,7 +2001,7 @@ ${JSON.stringify(
|
||||
);
|
||||
});
|
||||
|
||||
it('should recursively call sendMessageStream with "Please continue." when InvalidStream event is received for Gemini 2 models', async () => {
|
||||
it.skip('should recursively call sendMessageStream with "Please continue." when InvalidStream event is received for Gemini 2 models', async () => {
|
||||
vi.spyOn(client['config'], 'getContinueOnFailedApiCall').mockReturnValue(
|
||||
true,
|
||||
);
|
||||
@ -2063,7 +2067,7 @@ ${JSON.stringify(
|
||||
);
|
||||
});
|
||||
|
||||
it('should not recursively call sendMessageStream with "Please continue." when InvalidStream event is received and flag is false', async () => {
|
||||
it.skip('should not recursively call sendMessageStream with "Please continue." when InvalidStream event is received and flag is false', async () => {
|
||||
vi.spyOn(client['config'], 'getContinueOnFailedApiCall').mockReturnValue(
|
||||
false,
|
||||
);
|
||||
@ -2092,7 +2096,7 @@ ${JSON.stringify(
|
||||
|
||||
// Assert
|
||||
expect(events).toEqual([
|
||||
{ type: GeminiEventType.ModelInfo, value: 'default-routed-model' },
|
||||
{ type: GeminiEventType.ModelInfo, value: PREVIEW_GEMINI_FLASH_MODEL },
|
||||
{ type: GeminiEventType.InvalidStream },
|
||||
]);
|
||||
|
||||
@ -2100,7 +2104,7 @@ ${JSON.stringify(
|
||||
expect(mockTurnRunFn).toHaveBeenCalledTimes(1);
|
||||
});
|
||||
|
||||
it('should not retry with "Please continue." when InvalidStream event is received for non-Gemini-2 models', async () => {
|
||||
it.skip('should not retry with "Please continue." when InvalidStream event is received for non-Gemini-2 models', async () => {
|
||||
vi.spyOn(client['config'], 'getContinueOnFailedApiCall').mockReturnValue(
|
||||
true,
|
||||
);
|
||||
@ -2142,7 +2146,7 @@ ${JSON.stringify(
|
||||
expect(mockTurnRunFn).toHaveBeenCalledTimes(1);
|
||||
});
|
||||
|
||||
it('should stop recursing after one retry when InvalidStream events are repeatedly received', async () => {
|
||||
it.skip('should stop recursing after one retry when InvalidStream events are repeatedly received', async () => {
|
||||
vi.spyOn(client['config'], 'getContinueOnFailedApiCall').mockReturnValue(
|
||||
true,
|
||||
);
|
||||
@ -2452,7 +2456,7 @@ ${JSON.stringify(
|
||||
});
|
||||
});
|
||||
|
||||
describe('Availability Service Integration', () => {
|
||||
describe.skip('Availability Service Integration', () => {
|
||||
let mockAvailabilityService: ModelAvailabilityService;
|
||||
|
||||
beforeEach(() => {
|
||||
|
||||
@ -61,7 +61,6 @@ import {
|
||||
import { uiTelemetryService } from '../telemetry/uiTelemetry.js';
|
||||
import type { IdeContext, File } from '../ide/types.js';
|
||||
import { handleFallback } from '../fallback/handler.js';
|
||||
import type { RoutingContext } from '../routing/routingStrategy.js';
|
||||
import { debugLogger } from '../utils/debugLogger.js';
|
||||
import type { ModelConfigKey } from '../services/modelConfigService.js';
|
||||
import { ToolOutputMaskingService } from '../services/toolOutputMaskingService.js';
|
||||
@ -681,35 +680,13 @@ export class GeminiClient {
|
||||
);
|
||||
}
|
||||
|
||||
const routingContext: RoutingContext = {
|
||||
history: this.getChat().getHistory(/*curated=*/ true),
|
||||
request,
|
||||
signal,
|
||||
requestedModel: this.config.getModel(),
|
||||
};
|
||||
|
||||
let modelToUse: string;
|
||||
|
||||
// Determine Model (Stickiness vs. Routing)
|
||||
if (this.currentSequenceModel) {
|
||||
modelToUse = this.currentSequenceModel;
|
||||
} else {
|
||||
const router = this.config.getModelRouterService();
|
||||
const decision = await router.route(routingContext);
|
||||
modelToUse = decision.model;
|
||||
}
|
||||
const modelToUse = 'gemma-4-26b-a4b-it';
|
||||
|
||||
// availability logic
|
||||
const modelConfigKey: ModelConfigKey = {
|
||||
model: modelToUse,
|
||||
isChatModel: true,
|
||||
};
|
||||
const { model: finalModel } = applyModelSelection(
|
||||
this.config,
|
||||
modelConfigKey,
|
||||
{ consumeAttempt: false },
|
||||
);
|
||||
modelToUse = finalModel;
|
||||
|
||||
if (!signal.aborted && !this.currentSequenceModel) {
|
||||
yield { type: GeminiEventType.ModelInfo, value: modelToUse };
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user