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.
This commit is contained in:
Glucksberg
2026-01-31 13:02:06 +00:00
committed by Ayaan Zaidi
parent 1bea6907d6
commit dd84a42cc2

View File

@@ -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<Api> | null;
let model = modelRegistry.find(provider, modelId) as Model<Api> | 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<Api> | null;
}
if (!model) {
const providers = cfg?.models?.providers ?? {};
const inlineModels = buildInlineProviderModels(providers);