fix(opencode): preserve signed thinking during anthropic reorder (#30182)

This commit is contained in:
Aiden Cline
2026-06-02 23:33:48 -05:00
committed by GitHub
parent 0294342f77
commit 42173bca4b
2 changed files with 59 additions and 0 deletions

View File

@@ -230,6 +230,18 @@ 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") },