refactor: tighten codex inline api fallback follow-up

This commit is contained in:
Peter Steinberger
2026-03-08 13:54:03 +00:00
parent d2347ed825
commit d91d24e41d
2 changed files with 5 additions and 10 deletions

View File

@@ -641,14 +641,12 @@ describe("resolveModel", () => {
it("uses codex fallback when inline model omits api (#39682)", () => { it("uses codex fallback when inline model omits api (#39682)", () => {
mockOpenAICodexTemplateModel(); 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 = { const cfg: OpenClawConfig = {
models: { models: {
providers: { providers: {
"openai-codex": { "openai-codex": {
baseUrl: "https://custom.example.com", baseUrl: "https://custom.example.com",
headers: { "X-Custom-Auth": "token-123" },
models: [{ id: "gpt-5.4" }], models: [{ id: "gpt-5.4" }],
}, },
}, },
@@ -659,6 +657,8 @@ describe("resolveModel", () => {
expect(result.error).toBeUndefined(); expect(result.error).toBeUndefined();
expect(result.model).toMatchObject({ expect(result.model).toMatchObject({
api: "openai-codex-responses", api: "openai-codex-responses",
baseUrl: "https://custom.example.com",
headers: { "X-Custom-Auth": "token-123" },
id: "gpt-5.4", id: "gpt-5.4",
provider: "openai-codex", provider: "openai-codex",
}); });

View File

@@ -160,13 +160,8 @@ export function resolveModelWithRegistry(params: {
const inlineMatch = inlineModels.find( const inlineMatch = inlineModels.find(
(entry) => normalizeProviderId(entry.provider) === normalizedProvider && entry.id === modelId, (entry) => normalizeProviderId(entry.provider) === normalizedProvider && entry.id === modelId,
); );
if (inlineMatch) { if (inlineMatch?.api) {
// When the inline model already carries a concrete api, use it as-is. return normalizeModelCompat(inlineMatch as Model<Api>);
// 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<Api>);
}
} }
// Forward-compat fallbacks must be checked BEFORE the generic providerCfg fallback. // Forward-compat fallbacks must be checked BEFORE the generic providerCfg fallback.