mirror of
https://github.com/google-gemini/gemini-cli.git
synced 2026-05-13 05:12:55 -07:00
Remove useModelRouter experimental flag (#13593)
This commit is contained in:
@@ -25,18 +25,6 @@ Here's how it works:
|
|||||||
`packages/cli/src/zed-integration/zedIntegration.ts` which checks if
|
`packages/cli/src/zed-integration/zedIntegration.ts` which checks if
|
||||||
`isInFallbackMode()` is true.
|
`isInFallbackMode()` is true.
|
||||||
|
|
||||||
## Configuration
|
|
||||||
|
|
||||||
Model routing is controlled by the `useModelRouter` setting in your
|
|
||||||
`settings.json` file.
|
|
||||||
|
|
||||||
- **`"experimental.useModelRouter": true` (Default):** Enables the model
|
|
||||||
routing/fallback feature.
|
|
||||||
|
|
||||||
- **`"experimental.useModelRouter": false`:** Disables the model
|
|
||||||
routing/fallback feature. If a model fails, the CLI will not attempt to switch
|
|
||||||
to a fallback model.
|
|
||||||
|
|
||||||
### Model Selection Precedence
|
### Model Selection Precedence
|
||||||
|
|
||||||
The model used by Gemini CLI is determined by the following order of precedence:
|
The model used by Gemini CLI is determined by the following order of precedence:
|
||||||
@@ -50,7 +38,4 @@ The model used by Gemini CLI is determined by the following order of precedence:
|
|||||||
model specified in the `model.name` property of your `settings.json` file
|
model specified in the `model.name` property of your `settings.json` file
|
||||||
will be used.
|
will be used.
|
||||||
4. **Default Model:** If none of the above are set, the default model will be
|
4. **Default Model:** If none of the above are set, the default model will be
|
||||||
used. The default model is determined by the `useModelRouter` setting:
|
used. The default model is `auto`
|
||||||
- If `useModelRouter` is `true`, the default model is `"auto"`.
|
|
||||||
- If `useModelRouter` is `false`, the default model is the standard Gemini
|
|
||||||
model.
|
|
||||||
|
|||||||
@@ -107,7 +107,6 @@ they appear in the UI.
|
|||||||
### Experimental
|
### Experimental
|
||||||
|
|
||||||
| UI Label | Setting | Description | Default |
|
| UI Label | Setting | Description | Default |
|
||||||
| ----------------------------------- | ------------------------------------------------------- | ----------------------------------------------------------------------------- | ------- |
|
| ----------------------------------- | ------------------------------------------------------- | ------------------------------------------------------------ | ------- |
|
||||||
| Use Model Router | `experimental.useModelRouter` | Enable model routing to route requests to the best model based on complexity. | `true` |
|
|
||||||
| Enable Codebase Investigator | `experimental.codebaseInvestigatorSettings.enabled` | Enable the Codebase Investigator agent. | `true` |
|
| Enable Codebase Investigator | `experimental.codebaseInvestigatorSettings.enabled` | Enable the Codebase Investigator agent. | `true` |
|
||||||
| Codebase Investigator Max Num Turns | `experimental.codebaseInvestigatorSettings.maxNumTurns` | Maximum number of turns for the Codebase Investigator agent. | `10` |
|
| Codebase Investigator Max Num Turns | `experimental.codebaseInvestigatorSettings.maxNumTurns` | Maximum number of turns for the Codebase Investigator agent. | `10` |
|
||||||
|
|||||||
@@ -563,12 +563,6 @@ their corresponding top-level category object in your `settings.json` file.
|
|||||||
- **Default:** `false`
|
- **Default:** `false`
|
||||||
- **Requires restart:** Yes
|
- **Requires restart:** Yes
|
||||||
|
|
||||||
- **`experimental.useModelRouter`** (boolean):
|
|
||||||
- **Description:** Enable model routing to route requests to the best model
|
|
||||||
based on complexity.
|
|
||||||
- **Default:** `true`
|
|
||||||
- **Requires restart:** Yes
|
|
||||||
|
|
||||||
- **`experimental.codebaseInvestigatorSettings.enabled`** (boolean):
|
- **`experimental.codebaseInvestigatorSettings.enabled`** (boolean):
|
||||||
- **Description:** Enable the Codebase Investigator agent.
|
- **Description:** Enable the Codebase Investigator agent.
|
||||||
- **Default:** `true`
|
- **Default:** `true`
|
||||||
|
|||||||
@@ -9,8 +9,6 @@ import * as os from 'node:os';
|
|||||||
import * as path from 'node:path';
|
import * as path from 'node:path';
|
||||||
import {
|
import {
|
||||||
DEFAULT_FILE_FILTERING_OPTIONS,
|
DEFAULT_FILE_FILTERING_OPTIONS,
|
||||||
DEFAULT_GEMINI_MODEL,
|
|
||||||
DEFAULT_GEMINI_MODEL_AUTO,
|
|
||||||
OutputFormat,
|
OutputFormat,
|
||||||
SHELL_TOOL_NAME,
|
SHELL_TOOL_NAME,
|
||||||
WRITE_FILE_TOOL_NAME,
|
WRITE_FILE_TOOL_NAME,
|
||||||
@@ -1364,100 +1362,6 @@ describe('loadCliConfig model selection', () => {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('loadCliConfig model selection with model router', () => {
|
|
||||||
beforeEach(() => {
|
|
||||||
vi.spyOn(ExtensionManager.prototype, 'getExtensions').mockReturnValue([]);
|
|
||||||
});
|
|
||||||
|
|
||||||
afterEach(() => {
|
|
||||||
vi.resetAllMocks();
|
|
||||||
});
|
|
||||||
|
|
||||||
it('should use auto model when useModelRouter is true and no model is provided', async () => {
|
|
||||||
process.argv = ['node', 'script.js'];
|
|
||||||
const argv = await parseArguments({} as Settings);
|
|
||||||
const config = await loadCliConfig(
|
|
||||||
{
|
|
||||||
experimental: {
|
|
||||||
useModelRouter: true,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
'test-session',
|
|
||||||
argv,
|
|
||||||
);
|
|
||||||
|
|
||||||
expect(config.getModel()).toBe(DEFAULT_GEMINI_MODEL_AUTO);
|
|
||||||
});
|
|
||||||
|
|
||||||
it('should use default model when useModelRouter is false and no model is provided', async () => {
|
|
||||||
process.argv = ['node', 'script.js'];
|
|
||||||
const argv = await parseArguments({} as Settings);
|
|
||||||
const config = await loadCliConfig(
|
|
||||||
{
|
|
||||||
experimental: {
|
|
||||||
useModelRouter: false,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
'test-session',
|
|
||||||
argv,
|
|
||||||
);
|
|
||||||
|
|
||||||
expect(config.getModel()).toBe(DEFAULT_GEMINI_MODEL);
|
|
||||||
});
|
|
||||||
|
|
||||||
it('should prioritize argv over useModelRouter', async () => {
|
|
||||||
process.argv = ['node', 'script.js', '--model', 'gemini-from-argv'];
|
|
||||||
const argv = await parseArguments({} as Settings);
|
|
||||||
const config = await loadCliConfig(
|
|
||||||
{
|
|
||||||
experimental: {
|
|
||||||
useModelRouter: true,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
'test-session',
|
|
||||||
argv,
|
|
||||||
);
|
|
||||||
|
|
||||||
expect(config.getModel()).toBe('gemini-from-argv');
|
|
||||||
});
|
|
||||||
|
|
||||||
it('should prioritize settings over useModelRouter', async () => {
|
|
||||||
process.argv = ['node', 'script.js'];
|
|
||||||
const argv = await parseArguments({} as Settings);
|
|
||||||
const config = await loadCliConfig(
|
|
||||||
{
|
|
||||||
experimental: {
|
|
||||||
useModelRouter: true,
|
|
||||||
},
|
|
||||||
model: {
|
|
||||||
name: 'gemini-from-settings',
|
|
||||||
},
|
|
||||||
},
|
|
||||||
'test-session',
|
|
||||||
argv,
|
|
||||||
);
|
|
||||||
|
|
||||||
expect(config.getModel()).toBe('gemini-from-settings');
|
|
||||||
});
|
|
||||||
|
|
||||||
it('should prioritize environment variable over useModelRouter', async () => {
|
|
||||||
process.argv = ['node', 'script.js'];
|
|
||||||
vi.stubEnv('GEMINI_MODEL', 'gemini-from-env');
|
|
||||||
const argv = await parseArguments({} as Settings);
|
|
||||||
const config = await loadCliConfig(
|
|
||||||
{
|
|
||||||
experimental: {
|
|
||||||
useModelRouter: true,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
'test-session',
|
|
||||||
argv,
|
|
||||||
);
|
|
||||||
|
|
||||||
expect(config.getModel()).toBe('gemini-from-env');
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
describe('loadCliConfig folderTrust', () => {
|
describe('loadCliConfig folderTrust', () => {
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
vi.resetAllMocks();
|
vi.resetAllMocks();
|
||||||
@@ -1633,32 +1537,6 @@ describe('loadCliConfig useRipgrep', () => {
|
|||||||
const config = await loadCliConfig(settings, 'test-session', argv);
|
const config = await loadCliConfig(settings, 'test-session', argv);
|
||||||
expect(config.getUseRipgrep()).toBe(true);
|
expect(config.getUseRipgrep()).toBe(true);
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('loadCliConfig useModelRouter', () => {
|
|
||||||
it('should be true by default when useModelRouter is not set in settings', async () => {
|
|
||||||
process.argv = ['node', 'script.js'];
|
|
||||||
const argv = await parseArguments({} as Settings);
|
|
||||||
const settings: Settings = {};
|
|
||||||
const config = await loadCliConfig(settings, 'test-session', argv);
|
|
||||||
expect(config.getUseModelRouter()).toBe(true);
|
|
||||||
});
|
|
||||||
|
|
||||||
it('should be true when useModelRouter is set to true in settings', async () => {
|
|
||||||
process.argv = ['node', 'script.js'];
|
|
||||||
const argv = await parseArguments({} as Settings);
|
|
||||||
const settings: Settings = { experimental: { useModelRouter: true } };
|
|
||||||
const config = await loadCliConfig(settings, 'test-session', argv);
|
|
||||||
expect(config.getUseModelRouter()).toBe(true);
|
|
||||||
});
|
|
||||||
|
|
||||||
it('should be false when useModelRouter is explicitly set to false in settings', async () => {
|
|
||||||
process.argv = ['node', 'script.js'];
|
|
||||||
const argv = await parseArguments({} as Settings);
|
|
||||||
const settings: Settings = { experimental: { useModelRouter: false } };
|
|
||||||
const config = await loadCliConfig(settings, 'test-session', argv);
|
|
||||||
expect(config.getUseModelRouter()).toBe(false);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('screenReader configuration', () => {
|
describe('screenReader configuration', () => {
|
||||||
|
|||||||
@@ -15,7 +15,6 @@ import {
|
|||||||
setGeminiMdFilename as setServerGeminiMdFilename,
|
setGeminiMdFilename as setServerGeminiMdFilename,
|
||||||
getCurrentGeminiMdFilename,
|
getCurrentGeminiMdFilename,
|
||||||
ApprovalMode,
|
ApprovalMode,
|
||||||
DEFAULT_GEMINI_MODEL,
|
|
||||||
DEFAULT_GEMINI_MODEL_AUTO,
|
DEFAULT_GEMINI_MODEL_AUTO,
|
||||||
DEFAULT_GEMINI_EMBEDDING_MODEL,
|
DEFAULT_GEMINI_EMBEDDING_MODEL,
|
||||||
DEFAULT_FILE_FILTERING_OPTIONS,
|
DEFAULT_FILE_FILTERING_OPTIONS,
|
||||||
@@ -580,10 +579,7 @@ export async function loadCliConfig(
|
|||||||
extraExcludes.length > 0 ? extraExcludes : undefined,
|
extraExcludes.length > 0 ? extraExcludes : undefined,
|
||||||
);
|
);
|
||||||
|
|
||||||
const useModelRouter = settings.experimental?.useModelRouter ?? true;
|
const defaultModel = DEFAULT_GEMINI_MODEL_AUTO;
|
||||||
const defaultModel = useModelRouter
|
|
||||||
? DEFAULT_GEMINI_MODEL_AUTO
|
|
||||||
: DEFAULT_GEMINI_MODEL;
|
|
||||||
const resolvedModel: string =
|
const resolvedModel: string =
|
||||||
argv.model ||
|
argv.model ||
|
||||||
process.env['GEMINI_MODEL'] ||
|
process.env['GEMINI_MODEL'] ||
|
||||||
@@ -674,7 +670,6 @@ export async function loadCliConfig(
|
|||||||
output: {
|
output: {
|
||||||
format: (argv.outputFormat ?? settings.output?.format) as OutputFormat,
|
format: (argv.outputFormat ?? settings.output?.format) as OutputFormat,
|
||||||
},
|
},
|
||||||
useModelRouter,
|
|
||||||
enableMessageBusIntegration,
|
enableMessageBusIntegration,
|
||||||
codebaseInvestigatorSettings:
|
codebaseInvestigatorSettings:
|
||||||
settings.experimental?.codebaseInvestigatorSettings,
|
settings.experimental?.codebaseInvestigatorSettings,
|
||||||
|
|||||||
@@ -345,21 +345,6 @@ describe('SettingsSchema', () => {
|
|||||||
getSettingsSchema().general.properties.previewFeatures.description,
|
getSettingsSchema().general.properties.previewFeatures.description,
|
||||||
).toBe('Enable preview features (e.g., preview models).');
|
).toBe('Enable preview features (e.g., preview models).');
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should have useModelRouter setting in schema', () => {
|
|
||||||
expect(
|
|
||||||
getSettingsSchema().experimental.properties.useModelRouter,
|
|
||||||
).toBeDefined();
|
|
||||||
expect(
|
|
||||||
getSettingsSchema().experimental.properties.useModelRouter.type,
|
|
||||||
).toBe('boolean');
|
|
||||||
expect(
|
|
||||||
getSettingsSchema().experimental.properties.useModelRouter.category,
|
|
||||||
).toBe('Experimental');
|
|
||||||
expect(
|
|
||||||
getSettingsSchema().experimental.properties.useModelRouter.default,
|
|
||||||
).toBe(true);
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it('has JSON schema definitions for every referenced ref', () => {
|
it('has JSON schema definitions for every referenced ref', () => {
|
||||||
|
|||||||
@@ -1281,16 +1281,6 @@ const SETTINGS_SCHEMA = {
|
|||||||
'Enables extension loading/unloading within the CLI session.',
|
'Enables extension loading/unloading within the CLI session.',
|
||||||
showInDialog: false,
|
showInDialog: false,
|
||||||
},
|
},
|
||||||
useModelRouter: {
|
|
||||||
type: 'boolean',
|
|
||||||
label: 'Use Model Router',
|
|
||||||
category: 'Experimental',
|
|
||||||
requiresRestart: true,
|
|
||||||
default: true,
|
|
||||||
description:
|
|
||||||
'Enable model routing to route requests to the best model based on complexity.',
|
|
||||||
showInDialog: true,
|
|
||||||
},
|
|
||||||
codebaseInvestigatorSettings: {
|
codebaseInvestigatorSettings: {
|
||||||
type: 'object',
|
type: 'object',
|
||||||
label: 'Codebase Investigator Settings',
|
label: 'Codebase Investigator Settings',
|
||||||
|
|||||||
@@ -95,7 +95,6 @@ describe('BuiltinCommandLoader', () => {
|
|||||||
vi.clearAllMocks();
|
vi.clearAllMocks();
|
||||||
mockConfig = {
|
mockConfig = {
|
||||||
getFolderTrust: vi.fn().mockReturnValue(true),
|
getFolderTrust: vi.fn().mockReturnValue(true),
|
||||||
getUseModelRouter: () => false,
|
|
||||||
getEnableMessageBusIntegration: () => false,
|
getEnableMessageBusIntegration: () => false,
|
||||||
getEnableExtensionReloading: () => false,
|
getEnableExtensionReloading: () => false,
|
||||||
} as unknown as Config;
|
} as unknown as Config;
|
||||||
@@ -168,28 +167,6 @@ describe('BuiltinCommandLoader', () => {
|
|||||||
expect(permissionsCmd).toBeUndefined();
|
expect(permissionsCmd).toBeUndefined();
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should include modelCommand when getUseModelRouter is true', async () => {
|
|
||||||
const mockConfigWithModelRouter = {
|
|
||||||
...mockConfig,
|
|
||||||
getUseModelRouter: () => true,
|
|
||||||
} as unknown as Config;
|
|
||||||
const loader = new BuiltinCommandLoader(mockConfigWithModelRouter);
|
|
||||||
const commands = await loader.loadCommands(new AbortController().signal);
|
|
||||||
const modelCmd = commands.find((c) => c.name === 'model');
|
|
||||||
expect(modelCmd).toBeDefined();
|
|
||||||
});
|
|
||||||
|
|
||||||
it('should not include modelCommand when getUseModelRouter is false', async () => {
|
|
||||||
const mockConfigWithoutModelRouter = {
|
|
||||||
...mockConfig,
|
|
||||||
getUseModelRouter: () => false,
|
|
||||||
} as unknown as Config;
|
|
||||||
const loader = new BuiltinCommandLoader(mockConfigWithoutModelRouter);
|
|
||||||
const commands = await loader.loadCommands(new AbortController().signal);
|
|
||||||
const modelCmd = commands.find((c) => c.name === 'model');
|
|
||||||
expect(modelCmd).toBeUndefined();
|
|
||||||
});
|
|
||||||
|
|
||||||
it('should include policies command when message bus integration is enabled', async () => {
|
it('should include policies command when message bus integration is enabled', async () => {
|
||||||
const mockConfigWithMessageBus = {
|
const mockConfigWithMessageBus = {
|
||||||
...mockConfig,
|
...mockConfig,
|
||||||
@@ -220,7 +197,6 @@ describe('BuiltinCommandLoader profile', () => {
|
|||||||
vi.resetModules();
|
vi.resetModules();
|
||||||
mockConfig = {
|
mockConfig = {
|
||||||
getFolderTrust: vi.fn().mockReturnValue(false),
|
getFolderTrust: vi.fn().mockReturnValue(false),
|
||||||
getUseModelRouter: () => false,
|
|
||||||
getCheckpointingEnabled: () => false,
|
getCheckpointingEnabled: () => false,
|
||||||
getEnableMessageBusIntegration: () => false,
|
getEnableMessageBusIntegration: () => false,
|
||||||
getEnableExtensionReloading: () => false,
|
getEnableExtensionReloading: () => false,
|
||||||
|
|||||||
@@ -73,7 +73,7 @@ export class BuiltinCommandLoader implements ICommandLoader {
|
|||||||
initCommand,
|
initCommand,
|
||||||
mcpCommand,
|
mcpCommand,
|
||||||
memoryCommand,
|
memoryCommand,
|
||||||
...(this.config?.getUseModelRouter() ? [modelCommand] : []),
|
modelCommand,
|
||||||
...(this.config?.getFolderTrust() ? [permissionsCommand] : []),
|
...(this.config?.getFolderTrust() ? [permissionsCommand] : []),
|
||||||
privacyCommand,
|
privacyCommand,
|
||||||
...(this.config?.getEnableMessageBusIntegration()
|
...(this.config?.getEnableMessageBusIntegration()
|
||||||
|
|||||||
@@ -51,7 +51,6 @@ const renderComponent = (
|
|||||||
getDebugMode: vi.fn(() => false),
|
getDebugMode: vi.fn(() => false),
|
||||||
getContentGeneratorConfig: vi.fn(() => ({ authType: 'mock' })),
|
getContentGeneratorConfig: vi.fn(() => ({ authType: 'mock' })),
|
||||||
getUseSmartEdit: vi.fn(() => false),
|
getUseSmartEdit: vi.fn(() => false),
|
||||||
getUseModelRouter: vi.fn(() => false),
|
|
||||||
getProxy: vi.fn(() => undefined),
|
getProxy: vi.fn(() => undefined),
|
||||||
isInteractive: vi.fn(() => false),
|
isInteractive: vi.fn(() => false),
|
||||||
|
|
||||||
|
|||||||
@@ -222,7 +222,6 @@ describe('useGeminiStream', () => {
|
|||||||
.fn()
|
.fn()
|
||||||
.mockReturnValue(contentGeneratorConfig),
|
.mockReturnValue(contentGeneratorConfig),
|
||||||
getUseSmartEdit: () => false,
|
getUseSmartEdit: () => false,
|
||||||
getUseModelRouter: () => false,
|
|
||||||
isInteractive: () => false,
|
isInteractive: () => false,
|
||||||
} as unknown as Config;
|
} as unknown as Config;
|
||||||
mockOnDebugMessage = vi.fn();
|
mockOnDebugMessage = vi.fn();
|
||||||
|
|||||||
@@ -74,7 +74,6 @@ const mockConfig = {
|
|||||||
authType: 'oauth-personal',
|
authType: 'oauth-personal',
|
||||||
}),
|
}),
|
||||||
getUseSmartEdit: () => false,
|
getUseSmartEdit: () => false,
|
||||||
getUseModelRouter: () => false,
|
|
||||||
getGeminiClient: () => null, // No client needed for these tests
|
getGeminiClient: () => null, // No client needed for these tests
|
||||||
getShellExecutionConfig: () => ({ terminalWidth: 80, terminalHeight: 24 }),
|
getShellExecutionConfig: () => ({ terminalWidth: 80, terminalHeight: 24 }),
|
||||||
getEnableMessageBusIntegration: () => false,
|
getEnableMessageBusIntegration: () => false,
|
||||||
|
|||||||
@@ -750,99 +750,6 @@ describe('Server Config (config.ts)', () => {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('Model Router with Auth', () => {
|
|
||||||
it('should disable model router by default for oauth-personal', async () => {
|
|
||||||
const config = new Config({
|
|
||||||
...baseParams,
|
|
||||||
useModelRouter: true,
|
|
||||||
});
|
|
||||||
await config.refreshAuth(AuthType.LOGIN_WITH_GOOGLE);
|
|
||||||
expect(config.getUseModelRouter()).toBe(true);
|
|
||||||
});
|
|
||||||
|
|
||||||
it('should enable model router by default for other auth types', async () => {
|
|
||||||
const config = new Config({
|
|
||||||
...baseParams,
|
|
||||||
useModelRouter: true,
|
|
||||||
});
|
|
||||||
await config.refreshAuth(AuthType.USE_GEMINI);
|
|
||||||
expect(config.getUseModelRouter()).toBe(true);
|
|
||||||
});
|
|
||||||
|
|
||||||
it('should disable model router for specified auth type', async () => {
|
|
||||||
const config = new Config({
|
|
||||||
...baseParams,
|
|
||||||
useModelRouter: true,
|
|
||||||
disableModelRouterForAuth: [AuthType.USE_GEMINI],
|
|
||||||
});
|
|
||||||
await config.refreshAuth(AuthType.USE_GEMINI);
|
|
||||||
expect(config.getUseModelRouter()).toBe(false);
|
|
||||||
});
|
|
||||||
|
|
||||||
it('should enable model router for other auth type', async () => {
|
|
||||||
const config = new Config({
|
|
||||||
...baseParams,
|
|
||||||
useModelRouter: true,
|
|
||||||
disableModelRouterForAuth: [],
|
|
||||||
});
|
|
||||||
await config.refreshAuth(AuthType.LOGIN_WITH_GOOGLE);
|
|
||||||
expect(config.getUseModelRouter()).toBe(true);
|
|
||||||
});
|
|
||||||
|
|
||||||
it('should keep model router disabled when useModelRouter is false', async () => {
|
|
||||||
const config = new Config({
|
|
||||||
...baseParams,
|
|
||||||
useModelRouter: false,
|
|
||||||
disableModelRouterForAuth: [AuthType.USE_GEMINI],
|
|
||||||
});
|
|
||||||
await config.refreshAuth(AuthType.LOGIN_WITH_GOOGLE);
|
|
||||||
expect(config.getUseModelRouter()).toBe(false);
|
|
||||||
});
|
|
||||||
|
|
||||||
it('should keep the user-chosen model after refreshAuth, even when model router is disabled for the auth type', async () => {
|
|
||||||
const config = new Config({
|
|
||||||
...baseParams,
|
|
||||||
useModelRouter: true,
|
|
||||||
disableModelRouterForAuth: [AuthType.USE_GEMINI],
|
|
||||||
});
|
|
||||||
const chosenModel = 'gemini-1.5-pro-latest';
|
|
||||||
config.setModel(chosenModel);
|
|
||||||
|
|
||||||
await config.refreshAuth(AuthType.USE_GEMINI);
|
|
||||||
|
|
||||||
expect(config.getUseModelRouter()).toBe(false);
|
|
||||||
expect(config.getModel()).toBe(chosenModel);
|
|
||||||
});
|
|
||||||
|
|
||||||
it('should keep the user-chosen model after refreshAuth, when model router is enabled for the auth type', async () => {
|
|
||||||
const config = new Config({
|
|
||||||
...baseParams,
|
|
||||||
useModelRouter: true,
|
|
||||||
disableModelRouterForAuth: [AuthType.USE_GEMINI],
|
|
||||||
});
|
|
||||||
const chosenModel = 'gemini-1.5-pro-latest';
|
|
||||||
config.setModel(chosenModel);
|
|
||||||
|
|
||||||
await config.refreshAuth(AuthType.LOGIN_WITH_GOOGLE);
|
|
||||||
|
|
||||||
expect(config.getUseModelRouter()).toBe(true);
|
|
||||||
expect(config.getModel()).toBe(chosenModel);
|
|
||||||
});
|
|
||||||
|
|
||||||
it('should NOT switch to auto model if cli provides specific model, even if router is enabled', async () => {
|
|
||||||
const config = new Config({
|
|
||||||
...baseParams,
|
|
||||||
useModelRouter: true,
|
|
||||||
model: 'gemini-flash-latest',
|
|
||||||
});
|
|
||||||
|
|
||||||
await config.refreshAuth(AuthType.LOGIN_WITH_GOOGLE);
|
|
||||||
|
|
||||||
expect(config.getUseModelRouter()).toBe(true);
|
|
||||||
expect(config.getModel()).toBe('gemini-flash-latest');
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
describe('ContinueOnFailedApiCall Configuration', () => {
|
describe('ContinueOnFailedApiCall Configuration', () => {
|
||||||
it('should default continueOnFailedApiCall to false when not provided', () => {
|
it('should default continueOnFailedApiCall to false when not provided', () => {
|
||||||
const config = new Config(baseParams);
|
const config = new Config(baseParams);
|
||||||
|
|||||||
@@ -48,7 +48,6 @@ import {
|
|||||||
DEFAULT_GEMINI_EMBEDDING_MODEL,
|
DEFAULT_GEMINI_EMBEDDING_MODEL,
|
||||||
DEFAULT_GEMINI_FLASH_MODEL,
|
DEFAULT_GEMINI_FLASH_MODEL,
|
||||||
DEFAULT_GEMINI_MODEL,
|
DEFAULT_GEMINI_MODEL,
|
||||||
DEFAULT_GEMINI_MODEL_AUTO,
|
|
||||||
DEFAULT_THINKING_MODE,
|
DEFAULT_THINKING_MODE,
|
||||||
} from './models.js';
|
} from './models.js';
|
||||||
import { shouldAttemptBrowserLaunch } from '../utils/browser.js';
|
import { shouldAttemptBrowserLaunch } from '../utils/browser.js';
|
||||||
@@ -288,7 +287,6 @@ export interface ConfigParameters {
|
|||||||
useWriteTodos?: boolean;
|
useWriteTodos?: boolean;
|
||||||
policyEngineConfig?: PolicyEngineConfig;
|
policyEngineConfig?: PolicyEngineConfig;
|
||||||
output?: OutputSettings;
|
output?: OutputSettings;
|
||||||
useModelRouter?: boolean;
|
|
||||||
enableMessageBusIntegration?: boolean;
|
enableMessageBusIntegration?: boolean;
|
||||||
disableModelRouterForAuth?: AuthType[];
|
disableModelRouterForAuth?: AuthType[];
|
||||||
codebaseInvestigatorSettings?: CodebaseInvestigatorSettings;
|
codebaseInvestigatorSettings?: CodebaseInvestigatorSettings;
|
||||||
@@ -402,9 +400,6 @@ export class Config {
|
|||||||
private readonly messageBus: MessageBus;
|
private readonly messageBus: MessageBus;
|
||||||
private readonly policyEngine: PolicyEngine;
|
private readonly policyEngine: PolicyEngine;
|
||||||
private readonly outputSettings: OutputSettings;
|
private readonly outputSettings: OutputSettings;
|
||||||
private useModelRouter: boolean;
|
|
||||||
private readonly initialUseModelRouter: boolean;
|
|
||||||
private readonly disableModelRouterForAuth?: AuthType[];
|
|
||||||
private readonly enableMessageBusIntegration: boolean;
|
private readonly enableMessageBusIntegration: boolean;
|
||||||
private readonly codebaseInvestigatorSettings: CodebaseInvestigatorSettings;
|
private readonly codebaseInvestigatorSettings: CodebaseInvestigatorSettings;
|
||||||
private readonly continueOnFailedApiCall: boolean;
|
private readonly continueOnFailedApiCall: boolean;
|
||||||
@@ -519,9 +514,6 @@ export class Config {
|
|||||||
this.enableToolOutputTruncation = params.enableToolOutputTruncation ?? true;
|
this.enableToolOutputTruncation = params.enableToolOutputTruncation ?? true;
|
||||||
this.useSmartEdit = params.useSmartEdit ?? true;
|
this.useSmartEdit = params.useSmartEdit ?? true;
|
||||||
this.useWriteTodos = params.useWriteTodos ?? true;
|
this.useWriteTodos = params.useWriteTodos ?? true;
|
||||||
this.initialUseModelRouter = params.useModelRouter ?? false;
|
|
||||||
this.useModelRouter = this.initialUseModelRouter;
|
|
||||||
this.disableModelRouterForAuth = params.disableModelRouterForAuth ?? [];
|
|
||||||
this.enableHooks = params.enableHooks ?? false;
|
this.enableHooks = params.enableHooks ?? false;
|
||||||
|
|
||||||
// Enable MessageBus integration if:
|
// Enable MessageBus integration if:
|
||||||
@@ -643,14 +635,6 @@ export class Config {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async refreshAuth(authMethod: AuthType) {
|
async refreshAuth(authMethod: AuthType) {
|
||||||
this.useModelRouter = this.initialUseModelRouter;
|
|
||||||
if (this.disableModelRouterForAuth?.includes(authMethod)) {
|
|
||||||
this.useModelRouter = false;
|
|
||||||
if (this.model === DEFAULT_GEMINI_MODEL_AUTO) {
|
|
||||||
this.model = DEFAULT_GEMINI_MODEL;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Vertex and Genai have incompatible encryption and sending history with
|
// Vertex and Genai have incompatible encryption and sending history with
|
||||||
// thoughtSignature from Genai to Vertex will fail, we need to strip them
|
// thoughtSignature from Genai to Vertex will fail, we need to strip them
|
||||||
if (
|
if (
|
||||||
@@ -1341,10 +1325,6 @@ export class Config {
|
|||||||
: OutputFormat.TEXT;
|
: OutputFormat.TEXT;
|
||||||
}
|
}
|
||||||
|
|
||||||
getUseModelRouter(): boolean {
|
|
||||||
return this.useModelRouter;
|
|
||||||
}
|
|
||||||
|
|
||||||
async getGitService(): Promise<GitService> {
|
async getGitService(): Promise<GitService> {
|
||||||
if (!this.gitService) {
|
if (!this.gitService) {
|
||||||
this.gitService = new GitService(this.targetDir, this.storage);
|
this.gitService = new GitService(this.targetDir, this.storage);
|
||||||
|
|||||||
@@ -216,7 +216,6 @@ describe('Gemini Client (client.ts)', () => {
|
|||||||
getChatCompression: vi.fn().mockReturnValue(undefined),
|
getChatCompression: vi.fn().mockReturnValue(undefined),
|
||||||
getSkipNextSpeakerCheck: vi.fn().mockReturnValue(false),
|
getSkipNextSpeakerCheck: vi.fn().mockReturnValue(false),
|
||||||
getUseSmartEdit: vi.fn().mockReturnValue(false),
|
getUseSmartEdit: vi.fn().mockReturnValue(false),
|
||||||
getUseModelRouter: vi.fn().mockReturnValue(false),
|
|
||||||
getShowModelInfoInChat: vi.fn().mockReturnValue(false),
|
getShowModelInfoInChat: vi.fn().mockReturnValue(false),
|
||||||
getContinueOnFailedApiCall: vi.fn(),
|
getContinueOnFailedApiCall: vi.fn(),
|
||||||
getProjectRoot: vi.fn().mockReturnValue('/test/project/root'),
|
getProjectRoot: vi.fn().mockReturnValue('/test/project/root'),
|
||||||
|
|||||||
@@ -248,7 +248,6 @@ function createMockConfig(overrides: Partial<Config> = {}): Config {
|
|||||||
getTruncateToolOutputLines: () => DEFAULT_TRUNCATE_TOOL_OUTPUT_LINES,
|
getTruncateToolOutputLines: () => DEFAULT_TRUNCATE_TOOL_OUTPUT_LINES,
|
||||||
getToolRegistry: () => defaultToolRegistry,
|
getToolRegistry: () => defaultToolRegistry,
|
||||||
getUseSmartEdit: () => false,
|
getUseSmartEdit: () => false,
|
||||||
getUseModelRouter: () => false,
|
|
||||||
getGeminiClient: () => null,
|
getGeminiClient: () => null,
|
||||||
getEnableMessageBusIntegration: () => false,
|
getEnableMessageBusIntegration: () => false,
|
||||||
getMessageBus: () => null,
|
getMessageBus: () => null,
|
||||||
|
|||||||
@@ -60,7 +60,6 @@ describe('executeToolCall', () => {
|
|||||||
DEFAULT_TRUNCATE_TOOL_OUTPUT_THRESHOLD,
|
DEFAULT_TRUNCATE_TOOL_OUTPUT_THRESHOLD,
|
||||||
getTruncateToolOutputLines: () => DEFAULT_TRUNCATE_TOOL_OUTPUT_LINES,
|
getTruncateToolOutputLines: () => DEFAULT_TRUNCATE_TOOL_OUTPUT_LINES,
|
||||||
getUseSmartEdit: () => false,
|
getUseSmartEdit: () => false,
|
||||||
getUseModelRouter: () => false,
|
|
||||||
getGeminiClient: () => null, // No client needed for these tests
|
getGeminiClient: () => null, // No client needed for these tests
|
||||||
getEnableMessageBusIntegration: () => false,
|
getEnableMessageBusIntegration: () => false,
|
||||||
getMessageBus: () => null,
|
getMessageBus: () => null,
|
||||||
|
|||||||
@@ -312,7 +312,7 @@ describe('ClearcutLogger', () => {
|
|||||||
|
|
||||||
it('logs all user settings', () => {
|
it('logs all user settings', () => {
|
||||||
const { logger } = setup({
|
const { logger } = setup({
|
||||||
config: { useSmartEdit: true, useModelRouter: true },
|
config: { useSmartEdit: true },
|
||||||
});
|
});
|
||||||
|
|
||||||
vi.stubEnv('TERM_PROGRAM', 'vscode');
|
vi.stubEnv('TERM_PROGRAM', 'vscode');
|
||||||
|
|||||||
@@ -1544,7 +1544,6 @@ describe('loggers', () => {
|
|||||||
getUsageStatisticsEnabled: () => true,
|
getUsageStatisticsEnabled: () => true,
|
||||||
getContentGeneratorConfig: () => null,
|
getContentGeneratorConfig: () => null,
|
||||||
getUseSmartEdit: () => null,
|
getUseSmartEdit: () => null,
|
||||||
getUseModelRouter: () => null,
|
|
||||||
isInteractive: () => false,
|
isInteractive: () => false,
|
||||||
} as unknown as Config;
|
} as unknown as Config;
|
||||||
|
|
||||||
@@ -1595,7 +1594,6 @@ describe('loggers', () => {
|
|||||||
getUsageStatisticsEnabled: () => true,
|
getUsageStatisticsEnabled: () => true,
|
||||||
getContentGeneratorConfig: () => null,
|
getContentGeneratorConfig: () => null,
|
||||||
getUseSmartEdit: () => null,
|
getUseSmartEdit: () => null,
|
||||||
getUseModelRouter: () => null,
|
|
||||||
isInteractive: () => false,
|
isInteractive: () => false,
|
||||||
} as unknown as Config;
|
} as unknown as Config;
|
||||||
|
|
||||||
@@ -1648,7 +1646,6 @@ describe('loggers', () => {
|
|||||||
getUsageStatisticsEnabled: () => true,
|
getUsageStatisticsEnabled: () => true,
|
||||||
getContentGeneratorConfig: () => null,
|
getContentGeneratorConfig: () => null,
|
||||||
getUseSmartEdit: () => null,
|
getUseSmartEdit: () => null,
|
||||||
getUseModelRouter: () => null,
|
|
||||||
isInteractive: () => false,
|
isInteractive: () => false,
|
||||||
} as unknown as Config;
|
} as unknown as Config;
|
||||||
|
|
||||||
|
|||||||
@@ -90,7 +90,6 @@ describe('SmartEditTool', () => {
|
|||||||
getSessionId: vi.fn(() => 'mock-session-id'),
|
getSessionId: vi.fn(() => 'mock-session-id'),
|
||||||
getContentGeneratorConfig: vi.fn(() => ({ authType: 'mock' })),
|
getContentGeneratorConfig: vi.fn(() => ({ authType: 'mock' })),
|
||||||
getUseSmartEdit: vi.fn(() => false),
|
getUseSmartEdit: vi.fn(() => false),
|
||||||
getUseModelRouter: vi.fn(() => false),
|
|
||||||
getProxy: vi.fn(() => undefined),
|
getProxy: vi.fn(() => undefined),
|
||||||
getGeminiClient: vi.fn().mockReturnValue(geminiClient),
|
getGeminiClient: vi.fn().mockReturnValue(geminiClient),
|
||||||
getBaseLlmClient: vi.fn().mockReturnValue(baseLlmClient),
|
getBaseLlmClient: vi.fn().mockReturnValue(baseLlmClient),
|
||||||
|
|||||||
@@ -1201,13 +1201,6 @@
|
|||||||
"default": false,
|
"default": false,
|
||||||
"type": "boolean"
|
"type": "boolean"
|
||||||
},
|
},
|
||||||
"useModelRouter": {
|
|
||||||
"title": "Use Model Router",
|
|
||||||
"description": "Enable model routing to route requests to the best model based on complexity.",
|
|
||||||
"markdownDescription": "Enable model routing to route requests to the best model based on complexity.\n\n- Category: `Experimental`\n- Requires restart: `yes`\n- Default: `true`",
|
|
||||||
"default": true,
|
|
||||||
"type": "boolean"
|
|
||||||
},
|
|
||||||
"codebaseInvestigatorSettings": {
|
"codebaseInvestigatorSettings": {
|
||||||
"title": "Codebase Investigator Settings",
|
"title": "Codebase Investigator Settings",
|
||||||
"description": "Configuration for Codebase Investigator.",
|
"description": "Configuration for Codebase Investigator.",
|
||||||
|
|||||||
Reference in New Issue
Block a user