diff --git a/src/agents/pi-embedded-runner/model.test.ts b/src/agents/pi-embedded-runner/model.test.ts index 766765c415e..0dfde212a0a 100644 --- a/src/agents/pi-embedded-runner/model.test.ts +++ b/src/agents/pi-embedded-runner/model.test.ts @@ -641,14 +641,12 @@ describe("resolveModel", () => { it("uses codex fallback when inline model omits api (#39682)", () => { mockOpenAICodexTemplateModel(); - // When a user lists gpt-5.4 under openai-codex models without specifying - // an api, the inline match must not shadow the forward-compat resolver - // that supplies "openai-codex-responses". const cfg: OpenClawConfig = { models: { providers: { "openai-codex": { baseUrl: "https://custom.example.com", + headers: { "X-Custom-Auth": "token-123" }, models: [{ id: "gpt-5.4" }], }, }, @@ -659,6 +657,8 @@ describe("resolveModel", () => { expect(result.error).toBeUndefined(); expect(result.model).toMatchObject({ api: "openai-codex-responses", + baseUrl: "https://custom.example.com", + headers: { "X-Custom-Auth": "token-123" }, id: "gpt-5.4", provider: "openai-codex", }); diff --git a/src/agents/pi-embedded-runner/model.ts b/src/agents/pi-embedded-runner/model.ts index efb3112bd77..38d554a2bab 100644 --- a/src/agents/pi-embedded-runner/model.ts +++ b/src/agents/pi-embedded-runner/model.ts @@ -160,13 +160,8 @@ export function resolveModelWithRegistry(params: { const inlineMatch = inlineModels.find( (entry) => normalizeProviderId(entry.provider) === normalizedProvider && entry.id === modelId, ); - if (inlineMatch) { - // When the inline model already carries a concrete api, use it as-is. - // Otherwise fall through so forward-compat resolvers can supply the - // correct api (e.g. "openai-codex-responses" for gpt-5.4). #39682 - if (inlineMatch.api) { - return normalizeModelCompat(inlineMatch as Model); - } + if (inlineMatch?.api) { + return normalizeModelCompat(inlineMatch as Model); } // Forward-compat fallbacks must be checked BEFORE the generic providerCfg fallback.