Skip to content

Commit 1a31c7b

Browse files
committed
fix(catalog): cap live Codex discovery rows
1 parent 73bd6d0 commit 1a31c7b

2 files changed

Lines changed: 46 additions & 2 deletions

File tree

‎src/server/index.ts‎

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,8 @@ import {
4343
import { acquireServerBackgroundLifecycle } from "./background-lifecycle";
4444
import { runOpenAiTierStartupMigration } from "../providers/openai-tier-startup";
4545
import { runAlibabaRegionStartupMigration } from "../providers/alibaba-region-startup";
46-
import { isCanonicalOpenAiForwardProvider } from "../providers/openai-tiers";
46+
import { isCanonicalOpenAiForwardProvider, OPENAI_CODEX_PROVIDER_ID } from "../providers/openai-tiers";
47+
import { providerContextCap } from "../providers/context-cap";
4748
import { providerCodexAccountMode } from "../providers/registry";
4849
import type { StorageCleanupPolicy } from "../types";
4950
import {
@@ -911,7 +912,19 @@ export function startServer(port?: number, deps: StartServerDeps = {}): Server<W
911912
const catalogNativeSlugs = accountSelectors.length > 0
912913
? NATIVE_OPENAI_MODELS
913914
: nativeSlugs;
914-
const entries = buildCatalogEntries(loadCatalogTemplate(), catalogNativeSlugs, goOrdered, config.subagentModels, websocketsEnabled(config), maMode as "v1" | "default" | "v2", exactComboCatalogSlugs(config), accountSelectors, suppressedBareNativeSlugs);
915+
const entries = buildCatalogEntries(
916+
loadCatalogTemplate(),
917+
catalogNativeSlugs,
918+
goOrdered,
919+
config.subagentModels,
920+
websocketsEnabled(config),
921+
maMode as "v1" | "default" | "v2",
922+
exactComboCatalogSlugs(config),
923+
accountSelectors,
924+
suppressedBareNativeSlugs,
925+
new Set(),
926+
providerContextCap(config, OPENAI_CODEX_PROVIDER_ID),
927+
);
915928
return jsonResponse({
916929
models: applyNativeVisibility(
917930
entries,

‎tests/claude-models-discovery.test.ts‎

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -156,6 +156,37 @@ test("OpenAI list shape and Codex catalog shape stay unchanged", async () => {
156156
}
157157
});
158158

159+
test("Codex discovery applies the OpenAI context cap to native rows (#1430)", async () => {
160+
const config = configWithStaticModels();
161+
config.providers.openai = {
162+
adapter: "openai-responses",
163+
baseUrl: "https://chatgpt.com/backend-api/codex",
164+
liveModels: false,
165+
};
166+
config.providerContextCaps = { openai: 272_000 };
167+
saveConfig(config);
168+
const server = startServer(0);
169+
try {
170+
const response = await fetch(new URL("/v1/models?client_version=1.0.0", server.url));
171+
expect(response.status).toBe(200);
172+
const json = await response.json() as {
173+
models: Array<{
174+
slug: string;
175+
context_window?: number;
176+
max_context_window?: number;
177+
auto_compact_token_limit?: number;
178+
}>;
179+
};
180+
expect(json.models.find(model => model.slug === "gpt-5.6-sol")).toMatchObject({
181+
context_window: 272_000,
182+
max_context_window: 272_000,
183+
auto_compact_token_limit: 244_800,
184+
});
185+
} finally {
186+
await server.stop(true);
187+
}
188+
});
189+
159190
test("exact account disables affect only the matching OpenAI and Codex discovery row", async () => {
160191
const config = configWithStaticModels();
161192
config.providers.openai = {

0 commit comments

Comments
 (0)