From 2ce93382dd96dae787e426d7d097a809ceeeac5b Mon Sep 17 00:00:00 2001 From: Jerry-Xin Date: Mon, 16 Mar 2026 16:07:26 +0800 Subject: [PATCH] fix(image): fall back to text when configured OpenRouter input list is empty When a model has an explicitly configured but empty input array, the filter returns an empty array, leaving the model with no supported modalities. Apply the same empty-array guard used by the non-OpenRouter fallback path, defaulting to ["text"] when the filtered result is empty. --- src/agents/pi-embedded-runner/model.ts | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/agents/pi-embedded-runner/model.ts b/src/agents/pi-embedded-runner/model.ts index 35e692bc769..544690a3b34 100644 --- a/src/agents/pi-embedded-runner/model.ts +++ b/src/agents/pi-embedded-runner/model.ts @@ -317,11 +317,15 @@ export function resolveModelWithRegistry(params: { const configuredOpenRouterModel = providerConfig?.models?.find( (candidate) => candidate.id === modelId, ); - const resolvedInput: Array<"text" | "image"> = configuredOpenRouterModel?.input + const configuredInput = configuredOpenRouterModel?.input ? configuredOpenRouterModel.input.filter((item) => item === "text" || item === "image") - : isLikelyVisionModel(modelId) - ? ["text", "image"] - : ["text"]; + : undefined; + const resolvedInput: Array<"text" | "image"> = + configuredInput && configuredInput.length > 0 + ? configuredInput + : isLikelyVisionModel(modelId) + ? ["text", "image"] + : ["text"]; const providerHeaders = sanitizeModelHeaders(providerConfig?.headers, { stripSecretRefMarkers: true,