Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/codex/catalog.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// Public surface preserved exactly; importers keep using "src/codex/catalog".
export { isMediaGenerationModelId, shouldExposeRoutedModel, readCodexCatalogPath, readCatalog, normalizeRoutedCatalogEntry, catalogModelSlug, filterSupportedNativeSlugs, catalogModelSupportsReasoningSummaries } from "./catalog/parsing";
export type { CatalogModel, MultiAgentMode } from "./catalog/parsing";
export { accountBoundNativeOpenAiSlugs, accountBoundNativeOpenAiSlugsBySelector, CODEX_NATIVE_ALIAS_CATALOG_KIND, NATIVE_DAYBREAK_BLUE_MODEL, NATIVE_GPT56_CONTEXT_WINDOW, NATIVE_GPT56_MAX_INPUT_TOKENS, NATIVE_GPT56_OPT_IN_CONTEXT_WINDOW, NATIVE_OPENAI_CAPABILITY_ALIAS_MODELS, NATIVE_OPENAI_MODELS, configuredNativeAliasSlugs, desktopAllowlistSuppressedNativeSlugs, isNativeAliasCatalogEntry, isNativeOpenAiCapabilityAliasModel, nativeContextLimits, nativeOpenAiCapabilitySourceSlug, nativeOpenAiContextWindow, nativeOpenAiMaxInputTokens, disabledNativeSlugs, visibleNativeSlugs, desktopVisibleNativeSlugs, nativeModelRows, applyNativeVisibility, observedAccountBoundNativeEntries, observedAccountBoundNativeOpenAiSlugs, upstreamNativeEntry, nativeOpenAiSlugs, listCatalogNativeSlugs, nativeInputModalities, nativeReasoningEfforts, nativeDefaultReasoningEffort, shouldIncludeAccountBoundNativeOpenAi, shouldIncludeNativeOpenAi, type NativeContextLimits, type NativeContextLimitsInput } from "./catalog/metadata";
export { accountBoundNativeOpenAiSlugs, accountBoundNativeOpenAiSlugsBySelector, CODEX_NATIVE_ALIAS_CATALOG_KIND, NATIVE_DAYBREAK_BLUE_MODEL, NATIVE_GPT56_CONTEXT_WINDOW, NATIVE_GPT56_MAX_CONTEXT_WINDOW, NATIVE_GPT56_MAX_INPUT_TOKENS, NATIVE_GPT56_OPT_IN_CONTEXT_WINDOW, NATIVE_OPENAI_CAPABILITY_ALIAS_MODELS, NATIVE_OPENAI_MODELS, configuredNativeAliasSlugs, desktopAllowlistSuppressedNativeSlugs, isNativeAliasCatalogEntry, isNativeOpenAiCapabilityAliasModel, nativeContextLimits, nativeOpenAiCapabilitySourceSlug, nativeOpenAiContextWindow, nativeOpenAiMaxInputTokens, disabledNativeSlugs, visibleNativeSlugs, desktopVisibleNativeSlugs, nativeModelRows, applyNativeVisibility, observedAccountBoundNativeEntries, observedAccountBoundNativeOpenAiSlugs, upstreamNativeEntry, nativeOpenAiSlugs, listCatalogNativeSlugs, nativeInputModalities, nativeReasoningEfforts, nativeDefaultReasoningEffort, shouldIncludeAccountBoundNativeOpenAi, shouldIncludeNativeOpenAi, type NativeContextLimits, type NativeContextLimitsInput } from "./catalog/metadata";
export { isSpawnableCodexCandidate, codexExecInvocation, loadBundledCodexCatalog, materializeBundledCodexCatalog, loadCatalogTemplate } from "./catalog/bundled";
export { nativeEffortClamp, shouldApplyNativeEffortClamp, catalogModelEfforts, codexSupportedReasoningEfforts, clampedDefaultEffort, clampEntryToCodexSupportedEfforts, clampCatalogModelsToCodexSupport } from "./catalog/effort";
export { applyProviderConfigHints, isDatedVariantId, filterCatalogVisibleModels, gatherRoutedModels, clearGatherRoutedModelsInflight, augmentRoutedModelsWithRegistryOpenAiApiRows, augmentRoutedModelsWithMetadata, resolveComboCatalogMember, configuredComboTargetModelsByProvider } from "./catalog/provider-fetch";
Expand Down
19 changes: 15 additions & 4 deletions src/codex/catalog/metadata.ts
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,17 @@ export const NATIVE_GPT56_MAX_INPUT_TOKENS = 922_000;
/** User-facing 1M opt-in: the largest window the native 5.6 family may advertise. */
export const NATIVE_GPT56_OPT_IN_CONTEXT_WINDOW = NATIVE_GPT56_MAX_INPUT_TOKENS;

/**
* The native/upstream advertised max for the GPT-5.6 family.
*
* The live Codex catalog reports context_window 272000 against
* max_context_window 872000 (devlog E1). That upstream max is the default
* ceiling the catalog should advertise; the measured 922k ceiling
* (NATIVE_GPT56_MAX_INPUT_TOKENS) stays the opt-in target that user levers
* may raise to.
*/
export const NATIVE_GPT56_MAX_CONTEXT_WINDOW = 872_000;

const NATIVE_GPT56_FAMILY = new Set<string>([
"gpt-5.6-sol",
"gpt-5.6-terra",
Expand All @@ -148,15 +159,15 @@ export const NATIVE_OPENAI_CONTEXT_OVERRIDES: Record<string, { contextWindow?: n
"gpt-5.5": { contextWindow: 272_000, maxContextWindow: 272_000 },
"gpt-5.4": { contextWindow: 1_000_000, maxContextWindow: 1_000_000 },
"gpt-5.3-codex-spark": { contextWindow: 100_000, maxContextWindow: 100_000 },
"gpt-5.6-sol": { contextWindow: NATIVE_GPT56_CONTEXT_WINDOW, maxContextWindow: NATIVE_GPT56_MAX_INPUT_TOKENS, maxInputTokens: NATIVE_GPT56_MAX_INPUT_TOKENS },
"gpt-5.6-terra": { contextWindow: NATIVE_GPT56_CONTEXT_WINDOW, maxContextWindow: NATIVE_GPT56_MAX_INPUT_TOKENS, maxInputTokens: NATIVE_GPT56_MAX_INPUT_TOKENS },
"gpt-5.6-luna": { contextWindow: NATIVE_GPT56_CONTEXT_WINDOW, maxContextWindow: NATIVE_GPT56_MAX_INPUT_TOKENS, maxInputTokens: NATIVE_GPT56_MAX_INPUT_TOKENS },
"gpt-5.6-sol": { contextWindow: NATIVE_GPT56_CONTEXT_WINDOW, maxContextWindow: NATIVE_GPT56_MAX_CONTEXT_WINDOW, maxInputTokens: NATIVE_GPT56_MAX_INPUT_TOKENS },
"gpt-5.6-terra": { contextWindow: NATIVE_GPT56_CONTEXT_WINDOW, maxContextWindow: NATIVE_GPT56_MAX_CONTEXT_WINDOW, maxInputTokens: NATIVE_GPT56_MAX_INPUT_TOKENS },
"gpt-5.6-luna": { contextWindow: NATIVE_GPT56_CONTEXT_WINDOW, maxContextWindow: NATIVE_GPT56_MAX_CONTEXT_WINDOW, maxInputTokens: NATIVE_GPT56_MAX_INPUT_TOKENS },
// Daybreak Blue borrows Sol's capability metadata and rides the same family contract.
// Unlike sol/terra/luna its window was NOT measured here: this account cannot reach it
// (`400 "The 'gpt-daybreak-blue-latest' model is not supported when using Codex with a
// ChatGPT account."`), so the promotion rests on a report from an account that has
// access rather than on a probe. Treat it as the weaker evidence of the four.
[NATIVE_DAYBREAK_BLUE_MODEL]: { contextWindow: NATIVE_GPT56_CONTEXT_WINDOW, maxContextWindow: NATIVE_GPT56_MAX_INPUT_TOKENS, maxInputTokens: NATIVE_GPT56_MAX_INPUT_TOKENS },
[NATIVE_DAYBREAK_BLUE_MODEL]: { contextWindow: NATIVE_GPT56_CONTEXT_WINDOW, maxContextWindow: NATIVE_GPT56_MAX_CONTEXT_WINDOW, maxInputTokens: NATIVE_GPT56_MAX_INPUT_TOKENS },
};

const PINNED_UPSTREAM_MODELS: Map<string, RawEntry> = new Map(
Expand Down
27 changes: 21 additions & 6 deletions src/codex/catalog/parsing.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ import { redactSecretString } from "../../lib/redact";
import upstreamModelsSnapshot from "../data/upstream-models.json";


import { NATIVE_OPENAI_CONTEXT_OVERRIDES, SUPPORTED_NATIVE_OPENAI_SLUGS, UPSTREAM_NATIVE_ENTRIES, isNativeOpenAiCapabilityAliasModel, nativeMultiAgentVersion, nativeOpenAiContextWindow, nativeOpenAiMaxInputTokens, type NativeContextLimitsInput } from "./metadata";
import { NATIVE_GPT56_MAX_INPUT_TOKENS, NATIVE_OPENAI_CONTEXT_OVERRIDES, SUPPORTED_NATIVE_OPENAI_SLUGS, UPSTREAM_NATIVE_ENTRIES, isNativeOpenAiCapabilityAliasModel, nativeMultiAgentVersion, nativeOpenAiContextWindow, nativeOpenAiMaxInputTokens, type NativeContextLimitsInput } from "./metadata";
import { trustedAccountBoundNativeCatalogSlug } from "./account-models";
import { CODEX_NATIVE_ALIAS_CATALOG_KIND } from "./kinds";

Expand Down Expand Up @@ -296,10 +296,16 @@ function narrowNativeMaxContextWindow(
if (typeof value !== "number" || value <= 0) return value;
const resolved = nativeOpenAiContextWindow(slug, limits);
const authoritative = nativeOpenAiContextWindow(slug);
// The accessor pair tells us how far the levers moved this slug; apply the same delta to a
// field the accessor does not model, without ever raising it.
// The accessor pair tells us how far the levers moved this slug. Only narrow
// the max when the user actually lowered the window; otherwise keep the native
// max, which upstream advertises above the operating window (272k vs 872k).
if (resolved === undefined || authoritative === undefined) return value;
return Math.min(value, Math.max(resolved, 1));
// A configured provider cap independently clamps the advertised maximum, even
// when the resolved operating window was raised above the authoritative window.
const cap = typeof limits === "number" ? limits : limits?.cap;
const capped = applyProviderContextCap(value, cap) ?? value;
if (resolved < authoritative) return Math.min(capped, Math.max(resolved, 1));
return capped;
}

export function applyNativeOpenAiContextOverride(entry: RawEntry, limits?: NativeContextLimitsInput): void {
Expand All @@ -321,8 +327,17 @@ export function applyNativeOpenAiContextOverride(entry: RawEntry, limits?: Nativ
);
}
if (typeof override.maxContextWindow === "number") {
const maxContextWindow = narrowNativeMaxContextWindow(nativeSlug, override.maxContextWindow, limits);
entry.max_context_window = maxContextWindow;
const resolvedContext = nativeOpenAiContextWindow(nativeSlug, limits) ?? override.contextWindow;
const raised = typeof resolvedContext === "number"
&& typeof override.contextWindow === "number"
&& resolvedContext > override.contextWindow;
// Default rows advertise the native max (e.g. 872k for GPT-5.6) even though
// the operating window is 272k. When the user raises the window, the max
// follows the raise, capped at the measured ceiling (922k).
const maxContextWindow = raised
? Math.min(Math.max(override.maxContextWindow, resolvedContext), NATIVE_GPT56_MAX_INPUT_TOKENS)
: override.maxContextWindow;
entry.max_context_window = narrowNativeMaxContextWindow(nativeSlug, maxContextWindow, limits);
}
}
// providerContextCaps.openai is a ceiling for native OpenAI rows regardless of where the
Expand Down
9 changes: 5 additions & 4 deletions tests/claude-models-discovery.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import { saveConfig } from "../src/config";
import { handleManagementAPI } from "../src/server/management-api";
import { startServer } from "../src/server";
import type { OcxConfig } from "../src/types";
import { NATIVE_GPT56_CONTEXT_WINDOW, NATIVE_GPT56_MAX_CONTEXT_WINDOW } from "../src/codex/catalog";
import { installIsolatedCodexHome, type IsolatedCodexHome } from "./helpers/isolated-codex-home";
import { ManagementRequest } from "./helpers/management-auth";

Expand Down Expand Up @@ -165,7 +166,7 @@ test("Codex discovery applies the OpenAI context cap to native rows (#1430)", as
baseUrl: "https://chatgpt.com/backend-api/codex",
liveModels: false,
};
config.providerContextCaps = { openai: 272_000 };
config.providerContextCaps = { openai: NATIVE_GPT56_CONTEXT_WINDOW };
saveConfig(config);
const server = startServer(0);
try {
Expand All @@ -180,9 +181,9 @@ test("Codex discovery applies the OpenAI context cap to native rows (#1430)", as
}>;
};
expect(json.models.find(model => model.slug === "gpt-5.6-sol")).toMatchObject({
context_window: 272_000,
max_context_window: 272_000,
auto_compact_token_limit: 244_800,
context_window: NATIVE_GPT56_CONTEXT_WINDOW,
max_context_window: NATIVE_GPT56_MAX_CONTEXT_WINDOW,
auto_compact_token_limit: Math.floor(NATIVE_GPT56_CONTEXT_WINDOW * 0.9),
});
} finally {
await server.stop(true);
Expand Down
13 changes: 7 additions & 6 deletions tests/codex-catalog-sync-hardening.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { spawnSync } from "node:child_process";
import { tmpdir } from "node:os";
import { dirname, join, resolve } from "node:path";
import { fileURLToPath } from "node:url";
import { NATIVE_GPT56_CONTEXT_WINDOW, NATIVE_GPT56_MAX_CONTEXT_WINDOW, NATIVE_GPT56_MAX_INPUT_TOKENS } from "../src/codex/catalog";

const repoRoot = dirname(fileURLToPath(new URL("../package.json", import.meta.url)));

Expand Down Expand Up @@ -411,9 +412,9 @@ describe("Codex catalog sync hardening", () => {

const rows = JSON.parse(readFileSync(catalogPath, "utf8")).models as Array<Record<string, unknown>>;
expect(rows.find(row => row.slug === "team/gpt-daybreak-blue-latest")).toMatchObject({
context_window: 272_000,
max_context_window: 272_000,
auto_compact_token_limit: 244_800,
context_window: NATIVE_GPT56_CONTEXT_WINDOW,
max_context_window: NATIVE_GPT56_MAX_CONTEXT_WINDOW,
auto_compact_token_limit: Math.floor(NATIVE_GPT56_CONTEXT_WINDOW * 0.9),
comp_hash: "3000",
tool_mode: "code_mode_only",
use_responses_lite: true,
Expand Down Expand Up @@ -459,9 +460,9 @@ describe("Codex catalog sync hardening", () => {
const daybreak = rows.find(row => row.slug === "openai/gpt-daybreak-blue-latest");
expect(daybreak).toMatchObject({
display_name: "Daybreak Blue",
context_window: 922_000,
max_context_window: 922_000,
auto_compact_token_limit: 829_800,
context_window: NATIVE_GPT56_MAX_INPUT_TOKENS,
max_context_window: NATIVE_GPT56_MAX_INPUT_TOKENS,
auto_compact_token_limit: Math.floor(NATIVE_GPT56_MAX_INPUT_TOKENS * 0.9),
comp_hash: "3000",
tool_mode: "code_mode_only",
use_responses_lite: true,
Expand Down
Loading
Loading