Skip to content

Commit ce61c3b

Browse files
committed
Revert "šŸ› fix(opencode): strip thinking blocks from last assistant message"
This reverts commit 18b9492.
1 parent a2431d3 commit ce61c3b

2 files changed

Lines changed: 0 additions & 120 deletions

File tree

ā€Ždocs/09-temp/thinking-block-fix-design.mdā€Ž

Lines changed: 0 additions & 103 deletions
This file was deleted.

ā€Žpackages/opencode/src/session/message-v2.tsā€Ž

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -702,23 +702,6 @@ export namespace MessageV2 {
702702
}
703703
}
704704

705-
// Always strip reasoning/thinking parts from the last assistant message.
706-
// Claude API enforces that thinking blocks in the latest assistant message
707-
// must be byte-identical to the original response. Since OpenCode reconstructs
708-
// them from stored parts, they may not match exactly. Stripping is safe because
709-
// Claude doesn't need its own thinking blocks to continue the conversation.
710-
{
711-
const lastAssistantIdx = result.findLastIndex((msg) => msg.role === "assistant")
712-
if (lastAssistantIdx !== -1) {
713-
const filtered = result[lastAssistantIdx].parts.filter((part) => part.type !== "reasoning")
714-
if (filtered.length > 0 && !filtered.every((p) => p.type === "step-start")) {
715-
result[lastAssistantIdx].parts = filtered
716-
} else {
717-
result.splice(lastAssistantIdx, 1)
718-
}
719-
}
720-
}
721-
722705
const tools = Object.fromEntries(Array.from(toolNames).map((toolName) => [toolName, { toModelOutput }]))
723706

724707
return convertToModelMessages(

0 commit comments

Comments
Ā (0)