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);