GeezerVison is showing github.com — fix(opencode): allow integer GPT versions in Codex model filter (#47384) · anomalyco/opencode@500c46e
File treeExpand file treeCollapse file tree Open diff view settings Expand file treeCollapse file tree Open diff view settings Collapse file Copy file name to clipboardExpand all lines: packages/opencode/src/plugin/openai/codex.ts +1-1Lines changed: 1 addition & 1 deletion | Original file line number | Diff line number | Diff line change |
|---|
@@ -297,7 +297,7 @@ export async function CodexAuthPlugin(input: PluginInput, options: CodexAuthPlug | 297 | 297 | if (ALLOWED_MODELS.has(model.api.id)) return true | 298 | 298 | if (DISALLOWED_MODELS.has(model.api.id)) return false | 299 | 299 | if (model.api.id === "gpt-5.6") return false | 300 | | - const match = model.api.id.match(/^gpt-(\d+\.\d+)/) | | 300 | + const match = model.api.id.match(/^gpt-(\d+(?:\.\d+)?)/) | 301 | 301 | return match ? parseFloat(match[1]) > 5.4 : false | 302 | 302 | }) | 303 | 303 | .map(([modelID, model]) => [ | |
Collapse file Copy file name to clipboardExpand all lines: packages/opencode/test/plugin/codex.test.ts +23Lines changed: 23 additions & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -326,6 +326,29 @@ describe("plugin.codex", () => { | 326 | 326 | ) | 327 | 327 | }) | 328 | 328 |
| | 329 | + test.each([ | | 330 | + ["gpt-6-astra", true], | | 331 | + ["gpt-6", true], | | 332 | + ["gpt-6.0-astra", true], | | 333 | + ["gpt-7", true], | | 334 | + ["gpt-5", false], | | 335 | + ["gpt-4.1", false], | | 336 | + ["gpt-5.5-pro", false], | | 337 | + ["gpt-5.6", false], | | 338 | + ["not-a-gpt-model", false], | | 339 | + ])("filters OAuth model %s with integer or decimal versions", async (id, allowed) => { | | 340 | + const hooks = await CodexAuthPlugin({} as never) | | 341 | + const provider = { | | 342 | + models: { | | 343 | + [id]: { id, api: { id }, limit: {}, cost: {}, options: {} }, | | 344 | + }, | | 345 | + } | | 346 | + | | 347 | + const models = await hooks.provider!.models!(provider as never, { auth: { type: "oauth" } } as never) | | 348 | + | | 349 | + expect(Object.keys(models)).toEqual(allowed ? [id] : []) | | 350 | + }) | | 351 | + | 329 | 352 | test("deduplicates concurrent Codex token refreshes", async () => { | 330 | 353 | const refreshedAccess = createTestJwt({ | 331 | 354 | "https://api.openai.com/auth": { chatgpt_compute_residency: "eu" }, | |
|