Files
gemini-cli/packages/core/src/routing/strategies/overrideStrategy.ts
T
Sehoon Shon 17bf02b901 Update models menu dialog to support manual model selection and group… (#80)
* Update models menu dialog to support manual model selection and group by model family

* fix tests

* update codebase investigator model setting

* fix test

* fix test

* update generated golden file

* regenerate scheme and doc for settings

* use Preview Auto if previewFeatures is set to true
2025-12-16 13:23:57 -08:00

51 lines
1.3 KiB
TypeScript

/**
* @license
* Copyright 2025 Google LLC
* SPDX-License-Identifier: Apache-2.0
*/
import type { Config } from '../../config/config.js';
import {
DEFAULT_GEMINI_MODEL_AUTO,
getEffectiveModel,
PREVIEW_GEMINI_MODEL_AUTO,
} from '../../config/models.js';
import type { BaseLlmClient } from '../../core/baseLlmClient.js';
import type {
RoutingContext,
RoutingDecision,
RoutingStrategy,
} from '../routingStrategy.js';
/**
* Handles cases where the user explicitly specifies a model (override).
*/
export class OverrideStrategy implements RoutingStrategy {
readonly name = 'override';
async route(
_context: RoutingContext,
config: Config,
_baseLlmClient: BaseLlmClient,
): Promise<RoutingDecision | null> {
const overrideModel = config.getModel();
// If the model is 'auto' we should pass to the next strategy.
if (
overrideModel === DEFAULT_GEMINI_MODEL_AUTO ||
overrideModel === PREVIEW_GEMINI_MODEL_AUTO
)
return null;
// Return the overridden model name.
return {
model: getEffectiveModel(overrideModel, false),
metadata: {
source: this.name,
latencyMs: 0,
reasoning: `Routing bypassed by forced model directive. Using: ${overrideModel}`,
},
};
}
}