From b8b2799e36a6587cdbb25e2d7cc314cfff901733 Mon Sep 17 00:00:00 2001 From: Aiden Cline <63023139+rekram1-node@users.noreply.github.com> Date: Tue, 2 Jun 2026 23:33:54 -0500 Subject: [PATCH] =?UTF-8?q?Revert=20"fix(opencode):=20preserve=20signed=20?= =?UTF-8?q?thinking=20during=20anthropic=20reorder=20(#30=E2=80=A6"?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This reverts commit 42173bca4ba2f2c5e7faba827e1ade8a2a1b4b0a. --- packages/opencode/src/provider/transform.ts | 12 ----- .../opencode/test/provider/transform.test.ts | 47 ------------------- 2 files changed, 59 deletions(-) diff --git a/packages/opencode/src/provider/transform.ts b/packages/opencode/src/provider/transform.ts index f22e2543f9d9..c791aebf9713 100644 --- a/packages/opencode/src/provider/transform.ts +++ b/packages/opencode/src/provider/transform.ts @@ -230,18 +230,6 @@ function normalizeMessages( const parts = msg.content const first = parts.findIndex((part) => part.type === "tool-call") if (first === -1) return [msg] - // Anthropic signs thinking blocks, so moving them during replay invalidates the request. - if ( - parts - .slice(first) - .some( - (part) => - part.type === "reasoning" && - (part.providerOptions?.anthropic?.signature != null || - part.providerOptions?.anthropic?.redactedData != null), - ) - ) - return [msg] if (!parts.slice(first).some((part) => part.type !== "tool-call")) return [msg] return [ { ...msg, content: parts.filter((part) => part.type !== "tool-call") }, diff --git a/packages/opencode/test/provider/transform.test.ts b/packages/opencode/test/provider/transform.test.ts index 26c45f619413..7fb22ddf5770 100644 --- a/packages/opencode/test/provider/transform.test.ts +++ b/packages/opencode/test/provider/transform.test.ts @@ -1680,25 +1680,6 @@ describe("ProviderTransform.message - anthropic empty content filtering", () => ]) }) - test("leaves signed anthropic reasoning after tool calls unchanged", () => { - const msgs = [ - { - role: "assistant", - content: [ - { type: "reasoning", text: "First thought", providerOptions: { anthropic: { signature: "sig-1" } } }, - { type: "tool-call", toolCallId: "toolu_1", toolName: "read", input: { filePath: "/root" } }, - { type: "reasoning", text: "Second thought", providerOptions: { anthropic: { signature: "sig-2" } } }, - { type: "tool-call", toolCallId: "toolu_2", toolName: "glob", input: { pattern: "**/*.pdf" } }, - ], - }, - ] as any[] - - const result = ProviderTransform.message(msgs, anthropicModel, {}) as any[] - - expect(result).toHaveLength(1) - expect(result[0].content).toMatchObject(msgs[0].content) - }) - test("splits vertex anthropic assistant messages when text trails tool calls", () => { const model = { ...anthropicModel, @@ -1736,34 +1717,6 @@ describe("ProviderTransform.message - anthropic empty content filtering", () => ], }) }) - - test("leaves redacted vertex anthropic reasoning after tool calls unchanged", () => { - const model = { - ...anthropicModel, - providerID: "google-vertex-anthropic", - api: { - id: "claude-sonnet-4@20250514", - url: "https://us-central1-aiplatform.googleapis.com", - npm: "@ai-sdk/google-vertex/anthropic", - }, - } - - const msgs = [ - { - role: "assistant", - content: [ - { type: "tool-call", toolCallId: "toolu_1", toolName: "read", input: { filePath: "/root" } }, - { type: "reasoning", text: "", providerOptions: { anthropic: { redactedData: "redacted-1" } } }, - { type: "tool-call", toolCallId: "toolu_2", toolName: "glob", input: { pattern: "**/*.pdf" } }, - ], - }, - ] as any[] - - const result = ProviderTransform.message(msgs, model, {}) as any[] - - expect(result).toHaveLength(1) - expect(result[0].content).toMatchObject(msgs[0].content) - }) }) describe("ProviderTransform.message - strip openai metadata when store=false", () => {