From f6bfcfa5c626f913d4fcc3a0b81e86b8d5f7091f Mon Sep 17 00:00:00 2001 From: sbknana Date: Mon, 26 Jan 2026 14:43:00 -0500 Subject: [PATCH] fix: ensure api field is set for inline provider models When a model is found in the inline provider config (models.providers.*.models), the api field was not being set, causing "Unhandled API in mapOptionsForApi: undefined" errors when using custom OpenAI-compatible providers like Ollama or LM Studio. This fix ensures the api field is inherited from: 1. The model config itself (if specified) 2. The provider config's api field 3. Falls back to "openai-responses" (consistent with the fallback model behavior) Co-Authored-By: Claude Opus 4.5 --- src/agents/pi-embedded-runner/model.ts | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/agents/pi-embedded-runner/model.ts b/src/agents/pi-embedded-runner/model.ts index 15248aeaa..264c8348d 100644 --- a/src/agents/pi-embedded-runner/model.ts +++ b/src/agents/pi-embedded-runner/model.ts @@ -58,7 +58,13 @@ export function resolveModel( (entry) => normalizeProviderId(entry.provider) === normalizedProvider && entry.id === modelId, ); if (inlineMatch) { - const normalized = normalizeModelCompat(inlineMatch as Model); + // Ensure the api field is set from the provider config if not specified in the model + const providerCfg = providers[inlineMatch.provider]; + const modelWithApi = { + ...inlineMatch, + api: inlineMatch.api ?? providerCfg?.api ?? "openai-responses", + } as Model; + const normalized = normalizeModelCompat(modelWithApi); return { model: normalized, authStorage,