From 500c46ec79b818a44f7962e0707415ac3227c753 Mon Sep 17 00:00:00 2001 From: Aiden Cline <63023139+rekram1-node@users.noreply.github.com> Date: Fri, 4 Sep 2026 18:14:21 -0500 Subject: [PATCH] fix(opencode): allow integer GPT versions in Codex model filter (#47384) --- packages/opencode/src/plugin/openai/codex.ts | 2 +- packages/opencode/test/plugin/codex.test.ts | 23 ++++++++++++++++++++ 2 files changed, 24 insertions(+), 1 deletion(-) diff --git a/packages/opencode/src/plugin/openai/codex.ts b/packages/opencode/src/plugin/openai/codex.ts index 2ae34ac42f..89b4f322d0 100644 --- a/packages/opencode/src/plugin/openai/codex.ts +++ b/packages/opencode/src/plugin/openai/codex.ts @@ -297,7 +297,7 @@ export async function CodexAuthPlugin(input: PluginInput, options: CodexAuthPlug if (ALLOWED_MODELS.has(model.api.id)) return true if (DISALLOWED_MODELS.has(model.api.id)) return false if (model.api.id === "gpt-5.6") return false - const match = model.api.id.match(/^gpt-(\d+\.\d+)/) + const match = model.api.id.match(/^gpt-(\d+(?:\.\d+)?)/) return match ? parseFloat(match[1]) > 5.4 : false }) .map(([modelID, model]) => [ diff --git a/packages/opencode/test/plugin/codex.test.ts b/packages/opencode/test/plugin/codex.test.ts index fbc9df5932..a50f214447 100644 --- a/packages/opencode/test/plugin/codex.test.ts +++ b/packages/opencode/test/plugin/codex.test.ts @@ -326,6 +326,29 @@ describe("plugin.codex", () => { ) }) + test.each([ + ["gpt-6-astra", true], + ["gpt-6", true], + ["gpt-6.0-astra", true], + ["gpt-7", true], + ["gpt-5", false], + ["gpt-4.1", false], + ["gpt-5.5-pro", false], + ["gpt-5.6", false], + ["not-a-gpt-model", false], + ])("filters OAuth model %s with integer or decimal versions", async (id, allowed) => { + const hooks = await CodexAuthPlugin({} as never) + const provider = { + models: { + [id]: { id, api: { id }, limit: {}, cost: {}, options: {} }, + }, + } + + const models = await hooks.provider!.models!(provider as never, { auth: { type: "oauth" } } as never) + + expect(Object.keys(models)).toEqual(allowed ? [id] : []) + }) + test("deduplicates concurrent Codex token refreshes", async () => { const refreshedAccess = createTestJwt({ "https://api.openai.com/auth": { chatgpt_compute_residency: "eu" },