fix(core): tighten ChatGPT codex model eligibility
Replace the codex-substring heuristic with the empirically verified allow/disallow lists plus the >5.4 version rule; the ChatGPT backend rejects models like gpt-5.3-codex that the substring rule admitted.
This commit is contained in:
parent
781165c884
commit
f019bb3abf
2 changed files with 16 additions and 7 deletions
|
|
@ -181,7 +181,7 @@ export const OpenAIPlugin = define({
|
||||||
if (!chatgpt) continue
|
if (!chatgpt) continue
|
||||||
for (const model of item.models.values()) {
|
for (const model of item.models.values()) {
|
||||||
evt.model.update(item.provider.id, model.id, (draft) => {
|
evt.model.update(item.provider.id, model.id, (draft) => {
|
||||||
if (!eligible(draft)) {
|
if (!eligible(draft.api.id)) {
|
||||||
draft.enabled = false
|
draft.enabled = false
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
@ -316,8 +316,15 @@ function isChatGPT(credential: { readonly type: string; readonly methodID?: stri
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
function eligible(model: { readonly id: string }) {
|
const chatgptAllowed = new Set(["gpt-5.5", "gpt-5.3-codex-spark", "gpt-5.4", "gpt-5.4-mini"])
|
||||||
return model.id.includes("codex")
|
const chatgptDisallowed = new Set(["gpt-5.5-pro"])
|
||||||
|
|
||||||
|
/** Which API model ids a ChatGPT subscription may call through the codex backend. */
|
||||||
|
function eligible(apiID: string) {
|
||||||
|
if (chatgptAllowed.has(apiID)) return true
|
||||||
|
if (chatgptDisallowed.has(apiID)) return false
|
||||||
|
const match = apiID.match(/^gpt-(\d+\.\d+)/)
|
||||||
|
return match ? Number.parseFloat(match[1]) > 5.4 : false
|
||||||
}
|
}
|
||||||
|
|
||||||
function claim(token: string) {
|
function claim(token: string) {
|
||||||
|
|
|
||||||
|
|
@ -182,8 +182,8 @@ describe("OpenAIPlugin", () => {
|
||||||
catalog.provider.update(item.id, (draft) => {
|
catalog.provider.update(item.id, (draft) => {
|
||||||
draft.api = item.api
|
draft.api = item.api
|
||||||
})
|
})
|
||||||
catalog.model.update(item.id, ModelV2.ID.make("gpt-5-codex"), (draft) => {
|
catalog.model.update(item.id, ModelV2.ID.make("gpt-5.3-codex-spark"), (draft) => {
|
||||||
draft.api = { id: ModelV2.ID.make("gpt-5-codex"), type: "aisdk", package: "@ai-sdk/openai" }
|
draft.api = { id: ModelV2.ID.make("gpt-5.3-codex-spark"), type: "aisdk", package: "@ai-sdk/openai" }
|
||||||
draft.cost = [{ input: 1, output: 2, cache: { read: 3, write: 4 } }]
|
draft.cost = [{ input: 1, output: 2, cache: { read: 3, write: 4 } }]
|
||||||
})
|
})
|
||||||
catalog.model.update(item.id, ModelV2.ID.make("gpt-5"), (draft) => {
|
catalog.model.update(item.id, ModelV2.ID.make("gpt-5"), (draft) => {
|
||||||
|
|
@ -204,11 +204,13 @@ describe("OpenAIPlugin", () => {
|
||||||
|
|
||||||
yield* addPlugin()
|
yield* addPlugin()
|
||||||
|
|
||||||
expect(required(yield* catalog.model.get(ProviderV2.ID.openai, ModelV2.ID.make("gpt-5-codex")))).toMatchObject({
|
expect(
|
||||||
|
required(yield* catalog.model.get(ProviderV2.ID.openai, ModelV2.ID.make("gpt-5.3-codex-spark"))),
|
||||||
|
).toMatchObject({
|
||||||
enabled: true,
|
enabled: true,
|
||||||
api: {
|
api: {
|
||||||
type: "native",
|
type: "native",
|
||||||
id: "gpt-5-codex",
|
id: "gpt-5.3-codex-spark",
|
||||||
package: "@opencode-ai/llm/providers/openai/codex",
|
package: "@opencode-ai/llm/providers/openai/codex",
|
||||||
settings: { store: false },
|
settings: { store: false },
|
||||||
},
|
},
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue