فهرست منبع

fix(openai): use codex context limits for gpt-5.6 (#36248)

Co-authored-by: Aiden Cline <63023139+rekram1-node@users.noreply.github.com>
Nabs 1 ماه پیش
والد
کامیت
d7c0db8cee
2فایلهای تغییر یافته به همراه30 افزوده شده و 0 حذف شده
  1. 6 0
      packages/opencode/src/plugin/openai/codex.ts
  2. 24 0
      packages/opencode/test/plugin/codex.test.ts

+ 6 - 0
packages/opencode/src/plugin/openai/codex.ts

@@ -303,6 +303,12 @@ export async function CodexAuthPlugin(input: PluginInput, options: CodexAuthPlug
                       input: 272_000,
                       input: 272_000,
                       output: 128_000,
                       output: 128_000,
                     }
                     }
+                  : model.id.includes("gpt-5.6")
+                    ? {
+                        context: 500_000,
+                        input: 372_000,
+                        output: 128_000,
+                      }
                   : model.limit,
                   : model.limit,
               },
               },
             ]),
             ]),

+ 24 - 0
packages/opencode/test/plugin/codex.test.ts

@@ -149,6 +149,30 @@ describe("plugin.codex", () => {
     await enabled.dispose?.()
     await enabled.dispose?.()
   })
   })
 
 
+  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 provider = {
+      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)
+
+    expect(models["gpt-5.4"]?.limit).toEqual(limit)
+    expect(models["gpt-5.5"]?.limit).toEqual({ context: 400_000, input: 272_000, output: 128_000 })
+    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(await hooks.provider!.models!(provider as never, { auth: { type: "api" } } as never)).toBe(
+      provider.models as never,
+    )
+  })
+
   test("deduplicates concurrent Codex token refreshes", async () => {
   test("deduplicates concurrent Codex token refreshes", async () => {
     let auth = {
     let auth = {
       type: "oauth" as const,
       type: "oauth" as const,