From dd84a42cc2f69f77386314351d64242205033a2e Mon Sep 17 00:00:00 2001 From: Glucksberg Date: Sat, 31 Jan 2026 13:02:06 +0000 Subject: [PATCH] fix(model): resolve openrouter/auto model lookup mismatch (#5395) OpenRouter's 'auto' model is stored in the registry with the full id 'openrouter/auto', but parseModelRef splits 'openrouter/auto' into provider='openrouter' and modelId='auto'. The registry lookup then fails because it searches for id='auto' instead of 'openrouter/auto'. This adds a fallback that tries the full id when the initial lookup fails for this specific case. --- src/agents/pi-embedded-runner/model.ts | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/agents/pi-embedded-runner/model.ts b/src/agents/pi-embedded-runner/model.ts index 276938503b0..a960ac90458 100644 --- a/src/agents/pi-embedded-runner/model.ts +++ b/src/agents/pi-embedded-runner/model.ts @@ -57,7 +57,14 @@ export function resolveModel( const resolvedAgentDir = agentDir ?? resolveOpenClawAgentDir(); const authStorage = discoverAuthStorage(resolvedAgentDir); const modelRegistry = discoverModels(authStorage, resolvedAgentDir); - const model = modelRegistry.find(provider, modelId) as Model | null; + let model = modelRegistry.find(provider, modelId) as Model | null; + + // Fallback: OpenRouter's "auto" model is stored with full id "openrouter/auto" + // but parseModelRef splits it into provider="openrouter", modelId="auto" + if (!model && provider === "openrouter" && modelId === "auto") { + model = modelRegistry.find(provider, "openrouter/auto") as Model | null; + } + if (!model) { const providers = cfg?.models?.providers ?? {}; const inlineModels = buildInlineProviderModels(providers);