Skip to content

Commit afa04d6

Browse files
committed
fix(gateway): share codex model visibility
1 parent 85343ea commit afa04d6

3 files changed

Lines changed: 25 additions & 22 deletions

File tree

src/agents/model-catalog-visibility.test.ts

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,12 @@ describe("resolveVisibleModelCatalog", () => {
5858
name: "GPT 5.5",
5959
api: "openai-responses",
6060
},
61+
{
62+
provider: "openai",
63+
id: "gpt-5.4-codex",
64+
name: "GPT 5.4 Codex",
65+
api: "openai-responses",
66+
},
6167
];
6268

6369
const result = await resolveVisibleModelCatalog({
@@ -71,8 +77,16 @@ describe("resolveVisibleModelCatalog", () => {
7177
expect(authChecker).toHaveBeenNthCalledWith(1, "openai", "openai-responses");
7278
expect(authChecker).toHaveBeenNthCalledWith(2, "openai", "openai-responses");
7379
expect(authChecker).toHaveBeenNthCalledWith(3, "openai", "openai-chatgpt-responses");
74-
expect(authChecker).toHaveBeenCalledTimes(3);
80+
expect(authChecker).toHaveBeenNthCalledWith(4, "openai", "openai-responses");
81+
expect(authChecker).toHaveBeenNthCalledWith(5, "openai", "openai-chatgpt-responses");
82+
expect(authChecker).toHaveBeenCalledTimes(5);
7583
expect(result).toEqual([
84+
{
85+
provider: "openai",
86+
id: "gpt-5.4-codex",
87+
name: "GPT 5.4 Codex",
88+
api: "openai-responses",
89+
},
7690
{
7791
provider: "openai",
7892
id: "gpt-5.5",

src/agents/model-catalog-visibility.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,17 @@ import {
1414
} from "./model-visibility-policy.js";
1515

1616
type ModelCatalogVisibilityView = "default" | "configured" | "all";
17-
export type ProviderAuthChecker = (provider: string, modelApi?: string) => boolean | Promise<boolean>;
17+
export type ProviderAuthChecker = (
18+
provider: string,
19+
modelApi?: string,
20+
) => boolean | Promise<boolean>;
1821
const OPENAI_PROVIDER_ID = "openai";
1922
const OPENAI_CODEX_RESPONSES_API = "openai-chatgpt-responses";
2023
const OPENAI_CODEX_ROUTABLE_MODEL_IDS = new Set([
2124
"gpt-5.5",
2225
"gpt-5.5-pro",
2326
"gpt-5.4",
27+
"gpt-5.4-codex",
2428
"gpt-5.4-pro",
2529
"gpt-5.4-mini",
2630
]);
@@ -29,7 +33,7 @@ function isPromiseLike(value: boolean | Promise<boolean>): value is Promise<bool
2933
return typeof value === "object" && value !== null && typeof value.then === "function";
3034
}
3135

32-
function isCodexRoutableOpenAIPlatformCatalogEntry(entry: ModelCatalogEntry): boolean {
36+
export function isCodexRoutableOpenAIPlatformCatalogEntry(entry: ModelCatalogEntry): boolean {
3337
// OpenAI platform entries for current Codex-routable ids can use the ChatGPT
3438
// Responses auth path even when their catalog API is not already that API.
3539
return (

src/gateway/server-methods/models-list-result.ts

Lines changed: 4 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,10 @@ import {
2020
loadModelCatalogForBrowse,
2121
type ModelCatalogBrowseView,
2222
} from "../../agents/model-catalog-browse.js";
23-
import { resolveVisibleModelCatalog } from "../../agents/model-catalog-visibility.js";
23+
import {
24+
isCodexRoutableOpenAIPlatformCatalogEntry,
25+
resolveVisibleModelCatalog,
26+
} from "../../agents/model-catalog-visibility.js";
2427
import type { ModelCatalogEntry } from "../../agents/model-catalog.types.js";
2528
import { resolveDefaultAgentWorkspaceDir } from "../../agents/workspace.js";
2629
import type { OpenClawConfig } from "../../config/types.openclaw.js";
@@ -37,16 +40,7 @@ type ModelsListProviderAuthChecker = (
3740

3841
let loggedSlowModelsListCatalog = false;
3942
const OAUTH_REFRESH_MARGIN_MS = 5 * 60 * 1000;
40-
const OPENAI_PROVIDER_ID = "openai";
4143
const OPENAI_CODEX_RESPONSES_API = "openai-chatgpt-responses";
42-
const OPENAI_CODEX_ROUTABLE_MODEL_IDS = new Set([
43-
"gpt-5.5",
44-
"gpt-5.5-pro",
45-
"gpt-5.4",
46-
"gpt-5.4-codex",
47-
"gpt-5.4-pro",
48-
"gpt-5.4-mini",
49-
]);
5044

5145
// Unknown views are rejected by protocol validation first; this helper keeps the
5246
// handler default explicit for older clients that omit the field.
@@ -211,15 +205,6 @@ function createModelsListProviderAuthChecker(params: {
211205
);
212206
}
213207

214-
function isCodexRoutableOpenAIPlatformCatalogEntry(entry: ModelCatalogEntry): boolean {
215-
return (
216-
normalizeProviderId(entry.provider) === OPENAI_PROVIDER_ID &&
217-
entry.api !== undefined &&
218-
entry.api !== OPENAI_CODEX_RESPONSES_API &&
219-
OPENAI_CODEX_ROUTABLE_MODEL_IDS.has(entry.id.trim().toLowerCase())
220-
);
221-
}
222-
223208
async function resolveModelsListEntryAvailability(
224209
providerAuthChecker: ModelsListProviderAuthChecker,
225210
entry: ModelCatalogEntry,

0 commit comments

Comments
 (0)