diff --git a/packages/core/src/config/config.ts b/packages/core/src/config/config.ts index 11334e7a3f..e820a381fd 100644 --- a/packages/core/src/config/config.ts +++ b/packages/core/src/config/config.ts @@ -1928,6 +1928,15 @@ export class Config implements McpContext, AgentLoopContext { this.lastEmittedQuotaRemaining = undefined; this.lastEmittedQuotaLimit = undefined; this.emitQuotaChangedEvent(); + + // HYBRID AUTH TRIGGER: When changing model via /model, refresh auth + // so that hybrid mode (OpenAI + Google) is correctly initialized. + const newAuthType = getAuthTypeFromEnv(newModel); + if (newAuthType) { + this.refreshAuth(newAuthType).catch((err) => { + debugLogger.log(`[Config] Auth refresh failed on model switch: ${err.message}`); + }); + } } if (this.onModelChange && !isTemporary) { this.onModelChange(newModel);