Skip to content
Merged
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
27 changes: 25 additions & 2 deletions src/codex/catalog/metadata.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
21 changes: 20 additions & 1 deletion tests/native-model-toggle.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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({
Expand Down
Loading