Przeglądaj źródła

fix(opencode): support vertex opus adaptive reasoning (#29911)

Aiden Cline 3 miesięcy temu
rodzic
commit
b956e9a06f

+ 1 - 1
packages/opencode/src/provider/transform.ts

@@ -597,7 +597,7 @@ function openaiCompatibleReasoningEfforts(id: string) {
 }
 
 function anthropicOpus47OrLater(apiId: string) {
-  const version = /opus-(\d+)[.-](\d+)(?:[.-]|$)/i.exec(apiId)
+  const version = /opus-(\d+)[.-](\d+)(?:[.@-]|$)/i.exec(apiId)
   if (!version) return false
   const major = Number(version[1])
   const minor = Number(version[2])

+ 24 - 0
packages/opencode/test/provider/transform.test.ts

@@ -3298,6 +3298,30 @@ describe("ProviderTransform.variants", () => {
     })
   })
 
+  describe("@ai-sdk/google-vertex/anthropic", () => {
+    test("opus 4.8 uses adaptive reasoning for Vertex model IDs", () => {
+      const result = ProviderTransform.variants(
+        createMockModel({
+          id: "google-vertex-anthropic/claude-opus-4-8@default",
+          providerID: "google-vertex-anthropic",
+          api: {
+            id: "claude-opus-4-8@default",
+            url: "https://us-central1-aiplatform.googleapis.com",
+            npm: "@ai-sdk/google-vertex/anthropic",
+          },
+        }),
+      )
+      expect(Object.keys(result)).toEqual(["low", "medium", "high", "xhigh", "max"])
+      expect(result.high).toEqual({
+        thinking: {
+          type: "adaptive",
+          display: "summarized",
+        },
+        effort: "high",
+      })
+    })
+  })
+
   describe("@ai-sdk/amazon-bedrock", () => {
     test("anthropic sonnet 4.6 returns adaptive reasoning options", () => {
       const model = createMockModel({