From c2870fb5558a9ecdbfba44376479900591ba234f Mon Sep 17 00:00:00 2001 From: jun Date: Fri, 4 Sep 2026 10:17:35 +0900 Subject: [PATCH] fix(codex): let the 1M opt-in raise gpt-6-astra to its own ceiling The dashboard 1M toggle writes providerContextCaps.openai = 922000 for the whole native group, but narrowToLimits only RAISED a window for members of NATIVE_GPT56_FAMILY. Astra ships its own 272k/872k pair and was removed from that family so it would stop inheriting the measured 922k clamp, which silently took the opt-in path with it: the toggle moved every other native and left Astra pinned at 272k. Read the opt-in ceiling per slug instead. The family keeps its measured 922k; a self-described native uses its own maxContextWindow, so the shared 922k lever raises Astra to 872k rather than advertising a ceiling the model does not have. Verified live: with the toggle on, /v1/models reports 922000 for gpt-5.6-sol and 872000 for gpt-6-astra. --- src/codex/catalog/metadata.ts | 27 +++++++++++++++++++++++++-- tests/native-model-toggle.test.ts | 21 ++++++++++++++++++++- 2 files changed, 45 insertions(+), 3 deletions(-) diff --git a/src/codex/catalog/metadata.ts b/src/codex/catalog/metadata.ts index 91bd7107e5..439633f1e7 100644 --- a/src/codex/catalog/metadata.ts +++ b/src/codex/catalog/metadata.ts @@ -265,13 +265,36 @@ export function nativeContextLimits( } /** Apply the user levers to an authoritative value. */ +/** + * The ceiling a native slug may be RAISED to by a user lever, or undefined when it has no + * separate long window. + * + * This is what makes the dashboard's 1M opt-in work: without an opt-in ceiling a lever can only + * ever narrow the advertised window, so the toggle would appear to do nothing. The GPT-5.6 family + * shares one measured ceiling; a self-described native carries its own in + * `NATIVE_OPENAI_CONTEXT_OVERRIDES.maxContextWindow` (`gpt-6-astra` ships 872,000 against a + * 272,000 default), and reading it per-slug is what keeps the toggle honest for a model whose + * ceiling is not the family's. + */ +function longWindowOptInCeiling(slug: string): number | undefined { + if (NATIVE_GPT56_FAMILY.has(slug)) return NATIVE_GPT56_MAX_INPUT_TOKENS; + const override = NATIVE_OPENAI_CONTEXT_OVERRIDES[slug]; + const defaultWindow = positiveInt(override?.contextWindow); + const longWindow = positiveInt(override?.maxContextWindow); + if (defaultWindow === undefined || longWindow === undefined || longWindow <= defaultWindow) { + return undefined; + } + return longWindow; +} + function narrowToLimits(raw: number | undefined, slug: string, input: NativeContextLimitsInput): number | undefined { if (raw === undefined) return undefined; const limits = asLimits(input); const overlay = positiveInt(limits.modelWindows?.[slug]) ?? positiveInt(limits.providerWindow); const cap = positiveInt(limits.cap); - if (NATIVE_GPT56_FAMILY.has(slug)) { - const ceiling = NATIVE_GPT56_MAX_INPUT_TOKENS; + const optInCeiling = longWindowOptInCeiling(slug); + if (optInCeiling !== undefined) { + const ceiling = optInCeiling; const chosen = overlay ?? cap ?? raw; const window = Math.min(chosen, ceiling); return overlay !== undefined && cap !== undefined ? Math.min(window, cap) : window; diff --git a/tests/native-model-toggle.test.ts b/tests/native-model-toggle.test.ts index 4235a8f120..c17cb94475 100644 --- a/tests/native-model-toggle.test.ts +++ b/tests/native-model-toggle.test.ts @@ -25,7 +25,7 @@ import { } from "../src/codex/catalog"; import { handleManagementAPI } from "../src/server/management-api"; import { applyMultiAgentMode, applyNativeOpenAiContextOverride } from "../src/codex/catalog/parsing"; -import { NATIVE_GPT56_CONTEXT_WINDOW, NATIVE_GPT56_OPT_IN_CONTEXT_WINDOW, nativeOpenAiContextWindow } from "../src/codex/catalog"; +import { NATIVE_GPT56_CONTEXT_WINDOW, NATIVE_GPT56_OPT_IN_CONTEXT_WINDOW, nativeOpenAiContextTier, nativeOpenAiContextWindow } from "../src/codex/catalog"; import type { OcxConfig } from "../src/types"; import { ACCOUNT_GATED_NATIVE_OPENAI_MODELS } from "../src/codex/catalog/native-models"; import { @@ -117,6 +117,25 @@ describe("native GPT model toggles (bare slugs in disabledModels)", () => { expect(visibleNativeSlugs({ disabledModels: ["gpt-6-astra"] })).not.toContain("gpt-6-astra"); }); + test("the 1M opt-in raises gpt-6-astra to its own 872k ceiling, not the family's 922k", () => { + // The dashboard's native 1M toggle writes providerContextCaps.openai = 922_000 for the whole + // group. Raising a window only happens for slugs that HAVE an opt-in ceiling, which used to + // mean "member of NATIVE_GPT56_FAMILY". Astra ships its own 272k/872k pair and is not in that + // family, so the toggle moved every other native and left this one pinned at 272k. + const optIn = { cap: NATIVE_GPT56_OPT_IN_CONTEXT_WINDOW } as const; + + expect(nativeOpenAiContextWindow("gpt-6-astra")).toBe(272_000); + // Raised to the model's OWN ceiling: the 922k lever must not advertise 922k on a 872k model. + expect(nativeOpenAiContextWindow("gpt-6-astra", optIn)).toBe(872_000); + // The family keeps its measured ceiling, so the shared lever is not degraded for anyone else. + expect(nativeOpenAiContextWindow("gpt-5.6-sol", optIn)).toBe(922_000); + + // The tier pair is availability metadata and stays put either way — it is what told us the + // window SHOULD have moved while the window itself did not. + expect(nativeOpenAiContextTier("gpt-6-astra", optIn)) + .toEqual({ defaultWindow: 272_000, longWindow: 872_000 }); + }); + test("Direct bare rows use only main entitlement while Pool may use any eligible account", () => { seedCodexModelEntitlementsForTests("pool-a", ["gpt-daybreak-blue-latest"]); const direct = makeConfig({