Disable model routing for oauth users (#11889)

Co-authored-by: matt korwel <matt.korwel@gmail.com>
This commit is contained in:
Victor May
2025-10-28 18:25:53 -04:00
committed by GitHub
parent f6423ea45a
commit 601a639f95
2 changed files with 86 additions and 13 deletions
+20 -2
View File
@@ -46,6 +46,7 @@ import {
DEFAULT_GEMINI_EMBEDDING_MODEL,
DEFAULT_GEMINI_FLASH_MODEL,
DEFAULT_GEMINI_MODEL,
DEFAULT_GEMINI_MODEL_AUTO,
DEFAULT_THINKING_MODE,
} from './models.js';
import { shouldAttemptBrowserLaunch } from '../utils/browser.js';
@@ -279,6 +280,7 @@ export interface ConfigParameters {
output?: OutputSettings;
useModelRouter?: boolean;
enableMessageBusIntegration?: boolean;
disableModelRouterForAuth?: AuthType[];
codebaseInvestigatorSettings?: CodebaseInvestigatorSettings;
continueOnFailedApiCall?: boolean;
retryFetchErrors?: boolean;
@@ -377,7 +379,9 @@ export class Config {
private readonly messageBus: MessageBus;
private readonly policyEngine: PolicyEngine;
private readonly outputSettings: OutputSettings;
private readonly useModelRouter: boolean;
private useModelRouter: boolean;
private readonly initialUseModelRouter: boolean;
private readonly disableModelRouterForAuth?: AuthType[];
private readonly enableMessageBusIntegration: boolean;
private readonly codebaseInvestigatorSettings: CodebaseInvestigatorSettings;
private readonly continueOnFailedApiCall: boolean;
@@ -477,7 +481,11 @@ export class Config {
this.enableToolOutputTruncation = params.enableToolOutputTruncation ?? true;
this.useSmartEdit = params.useSmartEdit ?? true;
this.useWriteTodos = params.useWriteTodos ?? false;
this.useModelRouter = params.useModelRouter ?? false;
this.initialUseModelRouter = params.useModelRouter ?? false;
this.useModelRouter = this.initialUseModelRouter;
this.disableModelRouterForAuth = params.disableModelRouterForAuth ?? [
AuthType.LOGIN_WITH_GOOGLE,
];
this.enableMessageBusIntegration =
params.enableMessageBusIntegration ?? false;
this.codebaseInvestigatorSettings = {
@@ -551,6 +559,16 @@ export class Config {
}
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;
}
} else if (this.useModelRouter && this.model === DEFAULT_GEMINI_MODEL) {
this.model = DEFAULT_GEMINI_MODEL_AUTO;
}
// Vertex and Genai have incompatible encryption and sending history with
// thoughtSignature from Genai to Vertex will fail, we need to strip them
if (