diff --git a/packages/opencode/src/plugin/openai/codex.ts b/packages/opencode/src/plugin/openai/codex.ts index 89b4f322d0..6ead52c813 100644 --- a/packages/opencode/src/plugin/openai/codex.ts +++ b/packages/opencode/src/plugin/openai/codex.ts @@ -297,8 +297,11 @@ 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+)?)/) - return match ? parseFloat(match[1]) > 5.4 : false + const match = model.api.id.match(/^gpt-(\d+)(?:\.(\d+))?/) + if (!match) return false + const major = Number(match[1]) + const minor = Number(match[2] ?? 0) + return major > 5 || (major === 5 && minor > 4) }) .map(([modelID, model]) => [ modelID, diff --git a/packages/opencode/test/plugin/codex.test.ts b/packages/opencode/test/plugin/codex.test.ts index a50f214447..159f7806a7 100644 --- a/packages/opencode/test/plugin/codex.test.ts +++ b/packages/opencode/test/plugin/codex.test.ts @@ -331,12 +331,24 @@ describe("plugin.codex", () => { ["gpt-6", true], ["gpt-6.0-astra", true], ["gpt-7", true], + ["gpt-10", true], + ["gpt-5.5-astra", true], + ["gpt-5.9", true], + ["gpt-5.10", true], + ["gpt-5.10-astra", true], + ["gpt-5.40", true], ["gpt-5", false], + ["gpt-5.4-astra", false], + ["gpt-5.04-astra", false], ["gpt-4.1", false], + ["gpt-4.99", false], ["gpt-5.5-pro", false], ["gpt-5.6", false], + ["gpt-6garbage", true], + ["gpt-6.", true], + ["gpt-6.1.2", true], ["not-a-gpt-model", false], - ])("filters OAuth model %s with integer or decimal versions", async (id, allowed) => { + ])("filters OAuth model %s by GPT major and minor versions", async (id, allowed) => { const hooks = await CodexAuthPlugin({} as never) const provider = { models: {