mirror of
https://github.com/anomalyco/opencode.git
synced 2026-07-21 18:26:09 +00:00
fix(opencode): separate OAuth model filtering
This commit is contained in:
@@ -301,7 +301,6 @@ export async function CodexAuthPlugin(input: PluginInput, options: CodexAuthPlug
|
||||
.filter(([, model]) => {
|
||||
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
|
||||
})
|
||||
|
||||
@@ -152,19 +152,13 @@ describe("plugin.codex", () => {
|
||||
test("uses Codex context limits for OAuth GPT models", async () => {
|
||||
const hooks = await CodexAuthPlugin({} as never)
|
||||
const limit = { context: 1_050_000, input: 922_000, output: 128_000 }
|
||||
const ids = [
|
||||
"gpt-5.4",
|
||||
"gpt-5.5",
|
||||
"gpt-5.6",
|
||||
"gpt-5.6-luna",
|
||||
"gpt-5.6-luna-pro",
|
||||
"gpt-5.6-sol",
|
||||
"gpt-5.6-sol-pro",
|
||||
"gpt-5.6-terra",
|
||||
"gpt-5.6-terra-pro",
|
||||
]
|
||||
const provider = {
|
||||
models: Object.fromEntries(ids.map((id) => [id, { id, api: { id }, limit, cost: {} }])),
|
||||
models: Object.fromEntries(
|
||||
["gpt-5.4", "gpt-5.5", "gpt-5.6-sol", "gpt-5.6-terra", "gpt-5.6-luna"].map((id) => [
|
||||
id,
|
||||
{ id, api: { id }, limit, cost: {} },
|
||||
]),
|
||||
),
|
||||
}
|
||||
|
||||
const models = await hooks.provider!.models!(provider as never, { auth: { type: "oauth" } } as never)
|
||||
@@ -174,8 +168,6 @@ describe("plugin.codex", () => {
|
||||
expect(models["gpt-5.6-sol"]?.limit).toEqual({ context: 500_000, input: 372_000, output: 128_000 })
|
||||
expect(models["gpt-5.6-terra"]?.limit).toEqual({ context: 500_000, input: 372_000, output: 128_000 })
|
||||
expect(models["gpt-5.6-luna"]?.limit).toEqual({ context: 500_000, input: 372_000, output: 128_000 })
|
||||
expect(models["gpt-5.6"]).toBeUndefined()
|
||||
expect(Object.keys(models)).toEqual(ids.filter((id) => id !== "gpt-5.6"))
|
||||
expect(await hooks.provider!.models!(provider as never, { auth: { type: "api" } } as never)).toBe(
|
||||
provider.models as never,
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user