Skip to content

Commit 930c0a6

Browse files
sahrizviclaude
andauthored
fix(codex): add gpt-5.5 + gpt-5.6 to ChatGPT-subscription allowlist (closes AltimateAI#1132) (AltimateAI#1133)
* fix(codex): add gpt-5.5 + gpt-5.6 to ChatGPT-subscription allowlist Closes AltimateAI#1132. ChatGPT Pro/Plus (Codex tier) users couldn't select gpt-5.6 in the model picker even though OpenAI shipped it and `models.dev` (upstream catalog we regenerate `models-snapshot.ts` from at build time) has had it for a while. Root cause: the OAuth allowlist in packages/opencode/src/plugin/codex.ts hard-codes accepted model ids and hadn't been bumped past gpt-5.4-mini. Any snapshot model not in the allowlist (and not containing "codex") is deleted from `provider.models` at loader time — so gpt-5.6 never reached the picker. Fix: - Add `gpt-5.5` and `gpt-5.6` to `plugin/codex.ts`'s `OAUTH_ALLOWED_MODELS` (renamed + module-exported so it's unit- testable). Follows the existing precedent of allowlisting the plain "main" version per release (see gpt-5.2, gpt-5.4). Skips `pro`, `luna`, `sol`, `terra` variants — they're on models.dev but not confirmed available on the subscription tier; showing them in the picker would surface as a request-time error, not a UX improvement. - Also update `plugin/openai/codex.ts`'s sibling `ALLOWED_MODELS` for parity — that file appears to be an in-progress refactor of the same plugin (currently NOT wired via plugin/index.ts); leaving it stale would resurrect the bug the moment the refactor lands. Regression barrier: new `test/plugin/codex-allowlist.test.ts` asserts gpt-5.5 + gpt-5.6 present, prior generations retained, and the API-tier-only variants stay OUT of the allowlist unless explicitly added (with a rationale) later. Also a "no accidental truncation" size floor. 21/21 tests pass; typecheck clean; marker guard clean. Co-Authored-By: Claude Opus 4.7 <[email protected]> * fix(codex): address bot round — unify allowlist filter, revert upstream file Round 2 on AltimateAI#1133. Addresses coderabbit / kilo / cubic findings: - **plugin/codex.ts (fork-owned)**: extracted the OAuth model filter into a shared `shouldAllowOAuthModel(id)` helper (exported alongside `OAUTH_ALLOWED_MODELS`). The loader now delegates to it, so the allowlist AND the includes("codex") auto-allow are one source of truth. Dropped the 5 redundant *-codex entries from the set (they were already auto-allowed) — bots correctly flagged the comment contradicting the contents. Set is now 5 non-codex entries only. - **plugin/openai/codex.ts (upstream-shared)**: fully REVERTED my round-1 changes here. That file has an existing `parseFloat(match[1]) > 5.4` catch-all in its `models()` filter that already admits gpt-5.6, and its whole filtering policy is upstream's design choice. Overriding it in this bug fix would (a) be a divergence from upstream, (b) require altimate_change markers I hadn't added (marker guard rightly failed), and (c) reopen the "should we admit API-tier variants?" debate that isn't the point of this issue. That file is ALSO not the active plugin — plugin/index.ts imports from ./codex (the fork-owned one this PR does fix). Cleanest outcome: leave upstream alone, fix the fork's file, note the drift in the test file's docstring. - **test/plugin/codex-allowlist.test.ts**: expanded from 5 to 11 assertions. Splits into two describe blocks: • the CONSTANT (allowlist membership) — the prior barrier • the BEHAVIOR (`shouldAllowOAuthModel` filter) — new; catches breakage where a refactor stops consuming OAUTH_ALLOWED_MODELS, which the constant-only tests would silently pass. (cubic P3.) 26/26 tests pass; typecheck clean; marker guard will be clean once this commit lands (HEAD's diff-against-origin/main for the upstream file drops to zero after this commit). Co-Authored-By: Claude Opus 4.7 <[email protected]> * docs(codex): correct stale sibling-plugin ownership comments coderabbit MINOR round-3 catch: after reverting the plugin/openai/codex.ts changes, the docstring on `shouldAllowOAuthModel` and the test file's top comment still claimed the helper is "shared across both files" — that hasn't been true since I reverted openai/codex.ts. A future contributor reading the current tip would mistakenly assume the sibling filter has the same policy. Both docstrings now describe this as the ACTIVE plugin's policy (plugin/codex.ts, wired via plugin/index.ts) and explicitly call out that plugin/openai/codex.ts has its own separate filter with the parseFloat > 5.4 fallback — adopting the shared helper is followup on that file's refactor. Doc-only. 26/26 tests pass; typecheck clean; marker guard clean. Co-Authored-By: Claude Opus 4.7 <[email protected]> * docs(codex): correct loader comment (was still claiming shared policy) Round 4 doc fix on AltimateAI#1133. My previous docstring fix on `shouldAllowOAuthModel` correctly noted that plugin/openai/codex.ts has its own separate filter, but the LOADER comment 5 lines below still said "this filter and the sibling in plugin/openai/codex.ts share one source of truth" — kilo + cubic both flagged the contradiction independently. Rewrote the loader comment to match the helper docstring: this file is the active plugin, the sibling is an unwired refactor with its own ALLOWED_MODELS + parseFloat > 5.4 fallback, they do NOT share a source of truth today. Doc-only. 26/26 tests pass; typecheck clean; marker guard clean. Co-Authored-By: Claude Opus 4.7 <[email protected]> --------- Co-authored-by: Haider <[email protected]> Co-authored-by: Claude Opus 4.7 <[email protected]>
1 parent 3eafa30 commit 930c0a6

2 files changed

Lines changed: 171 additions & 14 deletions

File tree

‎packages/opencode/src/plugin/codex.ts‎

Lines changed: 42 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,36 @@ const CODEX_API_ENDPOINT = "https://chatgpt.com/backend-api/codex/responses"
1616
const OAUTH_PORT = 1455
1717
const OAUTH_POLLING_SAFETY_MARGIN_MS = 3000
1818

19+
/** Non-codex ChatGPT-subscription (OAuth) allowlist. Any modelId
20+
* containing "codex" is auto-allowed by ``shouldAllowOAuthModel`` below,
21+
* so this set only enumerates the plain non-codex main/mini variants
22+
* OpenAI exposes on Codex-tier accounts. Bump whenever a new gpt-5.N
23+
* is generally available on the subscription. Exported for unit-test
24+
* coverage — see test/plugin/codex-allowlist.test.ts. */
25+
export const OAUTH_ALLOWED_MODELS = new Set([
26+
"gpt-5.2",
27+
"gpt-5.4",
28+
"gpt-5.4-mini",
29+
"gpt-5.5",
30+
"gpt-5.6",
31+
])
32+
33+
/** OAuth (ChatGPT-subscription) model-filter policy for the ACTIVE plugin
34+
* (this file — wired via plugin/index.ts). A model is kept if either
35+
* (a) its id contains ``"codex"`` (all codex variants ship on the
36+
* subscription), or (b) its id is an exact member of
37+
* ``OAUTH_ALLOWED_MODELS`` (the curated non-codex releases).
38+
*
39+
* The sibling file plugin/openai/codex.ts (an in-progress refactor,
40+
* currently NOT wired) has its own separate filter with a
41+
* ``parseFloat(match[1]) > 5.4`` fallback. Adopting this helper is
42+
* followup work on that refactor — do NOT assume the two files share
43+
* this policy today. */
44+
export function shouldAllowOAuthModel(modelId: string): boolean {
45+
if (modelId.includes("codex")) return true
46+
return OAUTH_ALLOWED_MODELS.has(modelId)
47+
}
48+
1949
interface PkceCodes {
2050
verifier: string
2151
challenge: string
@@ -398,21 +428,19 @@ export async function CodexAuthPlugin(input: PluginInput): Promise<Hooks> {
398428
const auth = await getAuth()
399429
if (auth.type !== "oauth") return {}
400430

401-
// Filter models to only allowed Codex models for OAuth
402-
const allowedModels = new Set([
403-
"gpt-5.1-codex",
404-
"gpt-5.1-codex-max",
405-
"gpt-5.1-codex-mini",
406-
"gpt-5.2",
407-
"gpt-5.2-codex",
408-
"gpt-5.3-codex",
409-
"gpt-5.4",
410-
"gpt-5.4-mini",
411-
])
431+
// Filter models to only those the ChatGPT-subscription (Codex) tier
432+
// accepts. Delegates to ``shouldAllowOAuthModel`` (module-level,
433+
// above). See OAUTH_ALLOWED_MODELS + shouldAllowOAuthModel for the
434+
// criteria + how to add new gpt-5.N releases.
435+
//
436+
// NOTE: this file is the ACTIVE plugin (wired via plugin/index.ts).
437+
// The sibling plugin/openai/codex.ts is an unwired in-progress
438+
// refactor that keeps its OWN ALLOWED_MODELS + parseFloat > 5.4
439+
// fallback — this filter does NOT share a source of truth with it.
440+
// Adopting shouldAllowOAuthModel there is followup on that refactor.
441+
// (Closes #1132 — GPT 5.6 missing from picker.)
412442
for (const modelId of Object.keys(provider.models)) {
413-
if (modelId.includes("codex")) continue
414-
if (allowedModels.has(modelId)) continue
415-
delete provider.models[modelId]
443+
if (!shouldAllowOAuthModel(modelId)) delete provider.models[modelId]
416444
}
417445

418446
// Zero out costs for Codex (included with ChatGPT subscription)
Lines changed: 129 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,129 @@
1+
// Regression coverage for the ChatGPT-subscription (OAuth) model filter
2+
// in packages/opencode/src/plugin/codex.ts — the ACTIVE plugin wired
3+
// via plugin/index.ts.
4+
//
5+
// Filed as issue #1132: GPT 5.6 was released but the allowlist stopped
6+
// at 5.4, so users on ChatGPT Pro/Plus (Codex tier) couldn't pick it in
7+
// the model picker even though the underlying models.dev catalog had it.
8+
//
9+
// Sibling file plugin/openai/codex.ts is an in-progress refactor of the
10+
// same plugin, currently NOT wired via plugin/index.ts, and NOT covered
11+
// by this file — it has its own separate ``ALLOWED_MODELS`` + a
12+
// ``parseFloat > 5.4`` fallback in its ``models()`` filter, and its
13+
// existing test file (test/plugin/codex.test.ts) already covers its
14+
// OAuth-flow + JWT parsing internals. When that refactor is wired,
15+
// adopting ``shouldAllowOAuthModel`` here (and expanding this file's
16+
// coverage to the newly-active filter) is followup work.
17+
import { describe, expect, test } from "bun:test"
18+
import { OAUTH_ALLOWED_MODELS, shouldAllowOAuthModel } from "../../src/plugin/codex"
19+
20+
describe("OAUTH_ALLOWED_MODELS — subscription model picker regression barrier", () => {
21+
test("issue #1132: gpt-5.6 is present", () => {
22+
// If this fails again, someone dropped gpt-5.6 from the non-codex
23+
// allowlist without moving forward to a newer generation — rejecting
24+
// a shipped OpenAI model users have subscription access to.
25+
expect(OAUTH_ALLOWED_MODELS.has("gpt-5.6")).toBe(true)
26+
})
27+
28+
test("gpt-5.5 is present (added alongside 5.6 for parity)", () => {
29+
expect(OAUTH_ALLOWED_MODELS.has("gpt-5.5")).toBe(true)
30+
})
31+
32+
test("prior non-codex generations stay allowlisted (no accidental removal)", () => {
33+
for (const id of ["gpt-5.2", "gpt-5.4", "gpt-5.4-mini"]) {
34+
expect(OAUTH_ALLOWED_MODELS.has(id)).toBe(true)
35+
}
36+
})
37+
38+
test("codex-tagged variants are NOT in the non-codex set (they're auto-allowed instead)", () => {
39+
// The non-codex set is deliberately minimal — every codex-tagged id
40+
// is auto-allowed by shouldAllowOAuthModel's `includes("codex")` check
41+
// below, so listing them here would be redundant + a maintenance trap.
42+
for (const id of ["gpt-5.1-codex", "gpt-5.2-codex", "gpt-5.3-codex"]) {
43+
expect(OAUTH_ALLOWED_MODELS.has(id)).toBe(false)
44+
}
45+
})
46+
47+
test("allowlist does NOT include API-tier-only variants (defensive)", () => {
48+
// Pro / luna / sol / terra variants ship on models.dev but aren't
49+
// confirmed available on the ChatGPT-subscription (Codex) tier —
50+
// showing them in the picker would surface a request-time failure.
51+
// If OpenAI extends subscription coverage to them, add them here
52+
// deliberately (with a link to the announcement).
53+
for (const id of [
54+
"gpt-5.4-pro",
55+
"gpt-5.5-pro",
56+
"gpt-5.6-luna",
57+
"gpt-5.6-sol",
58+
"gpt-5.6-terra",
59+
]) {
60+
expect(OAUTH_ALLOWED_MODELS.has(id)).toBe(false)
61+
}
62+
})
63+
64+
test("allowlist size never regresses below current baseline", () => {
65+
// Trip-wire: if someone truncates the allowlist by mistake (or in
66+
// a bad rebase), the count drops and this test catches it before
67+
// shipping. Bump when a real new addition lands.
68+
expect(OAUTH_ALLOWED_MODELS.size).toBeGreaterThanOrEqual(5)
69+
})
70+
})
71+
72+
describe("shouldAllowOAuthModel — behavior of the filter itself", () => {
73+
// Behavior-level coverage: even if a refactor stops passing
74+
// OAUTH_ALLOWED_MODELS through, the filter function is what the
75+
// loader actually calls, so this catches breakage the constant-only
76+
// tests above would miss. (cubic P3 catch.)
77+
78+
test("allowlist members pass (spot-check each generation)", () => {
79+
for (const id of ["gpt-5.2", "gpt-5.4", "gpt-5.4-mini", "gpt-5.5", "gpt-5.6"]) {
80+
expect(shouldAllowOAuthModel(id)).toBe(true)
81+
}
82+
})
83+
84+
test("codex-tagged ids pass regardless of exact allowlist membership", () => {
85+
// Any id containing "codex" auto-passes — covers gpt-5.1-codex,
86+
// gpt-5.3-codex-spark, plus any future codex variant OpenAI ships.
87+
for (const id of [
88+
"gpt-5.1-codex",
89+
"gpt-5.1-codex-max",
90+
"gpt-5.1-codex-mini",
91+
"gpt-5.2-codex",
92+
"gpt-5.3-codex",
93+
"gpt-5.3-codex-spark",
94+
"gpt-5.3-codex-xhigh",
95+
"codex-hypothetical-future-name",
96+
]) {
97+
expect(shouldAllowOAuthModel(id)).toBe(true)
98+
}
99+
})
100+
101+
test("API-tier-only variants are rejected (the whole point of the filter)", () => {
102+
// These are the models the previous parseFloat > 5.4 fallback in
103+
// plugin/openai/codex.ts was incorrectly admitting; the shared
104+
// filter must reject them so the picker stays honest about what
105+
// the subscription actually accepts.
106+
for (const id of [
107+
"gpt-5.4-pro",
108+
"gpt-5.4-nano",
109+
"gpt-5.5-pro",
110+
"gpt-5.6-luna",
111+
"gpt-5.6-sol",
112+
"gpt-5.6-terra",
113+
]) {
114+
expect(shouldAllowOAuthModel(id)).toBe(false)
115+
}
116+
})
117+
118+
test("completely unrelated ids are rejected", () => {
119+
for (const id of [
120+
"claude-3.5-sonnet",
121+
"gemini-2.5-pro",
122+
"gpt-4o",
123+
"gpt-4-turbo",
124+
"",
125+
]) {
126+
expect(shouldAllowOAuthModel(id)).toBe(false)
127+
}
128+
})
129+
})

0 commit comments

Comments
 (0)