Skip to content

Commit 02a167e

Browse files
authored
fix(opencode): compare Codex GPT versions by major and minor (anomalyco#47385)
1 parent 500c46e commit 02a167e

2 files changed

Lines changed: 18 additions & 3 deletions

File tree

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

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -297,8 +297,11 @@ export async function CodexAuthPlugin(input: PluginInput, options: CodexAuthPlug
297297
if (ALLOWED_MODELS.has(model.api.id)) return true
298298
if (DISALLOWED_MODELS.has(model.api.id)) return false
299299
if (model.api.id === "gpt-5.6") return false
300-
const match = model.api.id.match(/^gpt-(\d+(?:\.\d+)?)/)
301-
return match ? parseFloat(match[1]) > 5.4 : false
300+
const match = model.api.id.match(/^gpt-(\d+)(?:\.(\d+))?/)
301+
if (!match) return false
302+
const major = Number(match[1])
303+
const minor = Number(match[2] ?? 0)
304+
return major > 5 || (major === 5 && minor > 4)
302305
})
303306
.map(([modelID, model]) => [
304307
modelID,

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

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -331,12 +331,24 @@ describe("plugin.codex", () => {
331331
["gpt-6", true],
332332
["gpt-6.0-astra", true],
333333
["gpt-7", true],
334+
["gpt-10", true],
335+
["gpt-5.5-astra", true],
336+
["gpt-5.9", true],
337+
["gpt-5.10", true],
338+
["gpt-5.10-astra", true],
339+
["gpt-5.40", true],
334340
["gpt-5", false],
341+
["gpt-5.4-astra", false],
342+
["gpt-5.04-astra", false],
335343
["gpt-4.1", false],
344+
["gpt-4.99", false],
336345
["gpt-5.5-pro", false],
337346
["gpt-5.6", false],
347+
["gpt-6garbage", true],
348+
["gpt-6.", true],
349+
["gpt-6.1.2", true],
338350
["not-a-gpt-model", false],
339-
])("filters OAuth model %s with integer or decimal versions", async (id, allowed) => {
351+
])("filters OAuth model %s by GPT major and minor versions", async (id, allowed) => {
340352
const hooks = await CodexAuthPlugin({} as never)
341353
const provider = {
342354
models: {

0 commit comments

Comments
 (0)