feat(config): add 'auto' alias for default model selection (#16661)

Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
This commit is contained in:
Sehoon Shon
2026-01-14 19:07:51 -05:00
committed by GitHub
parent b3527dc9e4
commit e58fca68ce
2 changed files with 21 additions and 5 deletions

View File

@@ -1313,6 +1313,20 @@ describe('loadCliConfig model selection', () => {
expect(config.getModel()).toBe('gemini-2.5-flash-preview');
});
it('selects the default auto model if provided via auto alias', async () => {
process.argv = ['node', 'script.js', '--model', 'auto'];
const argv = await parseArguments({} as Settings);
const config = await loadCliConfig(
{
// No model provided via settings.
},
'test-session',
argv,
);
expect(config.getModel()).toBe('auto-gemini-2.5');
});
});
describe('loadCliConfig folderTrust', () => {

View File

@@ -36,6 +36,7 @@ import {
type HookDefinition,
type HookEventName,
type OutputFormat,
GEMINI_MODEL_ALIAS_AUTO,
} from '@google/gemini-cli-core';
import type { Settings } from './settings.js';
import { saveModelChange, loadSettings } from './settings.js';
@@ -617,12 +618,13 @@ export async function loadCliConfig(
const defaultModel = settings.general?.previewFeatures
? PREVIEW_GEMINI_MODEL_AUTO
: DEFAULT_GEMINI_MODEL_AUTO;
const resolvedModel: string =
argv.model ||
process.env['GEMINI_MODEL'] ||
settings.model?.name ||
defaultModel;
const specifiedModel =
argv.model || process.env['GEMINI_MODEL'] || settings.model?.name;
const resolvedModel =
specifiedModel === GEMINI_MODEL_ALIAS_AUTO
? defaultModel
: specifiedModel || defaultModel;
const sandboxConfig = await loadSandboxConfig(settings, argv);
const screenReader =
argv.screenReader !== undefined