From abdd39da0065d3501209fabb46bdc758f5a8a66d Mon Sep 17 00:00:00 2001 From: MoerAI Date: Mon, 16 Mar 2026 10:58:51 +0900 Subject: [PATCH] fix(agent-registration): always attempt fallback when model resolution fails Removes both the isFirstRunNoCache and override?.model guards from the fallback logic in collectPendingBuiltinAgents(). Previously, when a user configured a model like minimax/MiniMax-M2.5 that wasn't in availableModels, the agent was silently excluded and --agent Librarian would crash with 'undefined is not an object'. Now: if applyModelResolution() fails for ANY reason (cache state, unavailable model, config merge issue), getFirstFallbackModel() is always attempted. A log warning is emitted when a user-configured model couldn't be resolved, making the previously silent failure visible. Supersedes #2517 Fixes #2427 --- src/agents/builtin-agents/general-agents.ts | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/agents/builtin-agents/general-agents.ts b/src/agents/builtin-agents/general-agents.ts index 7727cf999..f6cc4e1b2 100644 --- a/src/agents/builtin-agents/general-agents.ts +++ b/src/agents/builtin-agents/general-agents.ts @@ -8,6 +8,7 @@ import { buildAgent, isFactory } from "../agent-builder" import { applyOverrides } from "./agent-overrides" import { applyEnvironmentContext } from "./environment-context" import { applyModelResolution, getFirstFallbackModel } from "./model-resolution" +import { log } from "../../shared/logger" export function collectPendingBuiltinAgents(input: { agentSources: Record @@ -75,7 +76,13 @@ export function collectPendingBuiltinAgents(input: { availableModels, systemDefaultModel, }) - if (!resolution && isFirstRunNoCache && !override?.model) { + if (!resolution) { + if (override?.model) { + log("[agent-registration] User-configured model could not be resolved, falling back", { + agent: agentName, + configuredModel: override.model, + }) + } resolution = getFirstFallbackModel(requirement) } if (!resolution) continue