Description
In packages/opencode/src/provider/transform.ts, normalizeMessages() splits assistant turns where text trails tool-call blocks for Anthropic / Vertex Anthropic models. The current split filter groups only tool-call parts together and treats tool-result as non-tool content, so an assistant turn shaped like:
[tool-call, tool-result, text]
becomes:
msg A: [tool-result, text]
msg B: [tool-call]
After provider/SDK merge this still presents tool_use blocks without a paired tool_result immediately after, so Anthropic returns:
tool_use ids were found without tool_result blocks immediately after
OpenCode version
1.14.33 (also reproduces against current dev).
Steps to reproduce
- Use a Claude / Vertex Anthropic model.
- Have an assistant turn whose
content ends up shaped like [tool-call, tool-result, text] or [tool-call, text, tool-result] (this can happen during reconstruction or when tool-result is co-located with the originating tool-call).
- Send another user turn so the assistant turn is replayed in
normalizeMessages().
- The provider rejects the request with
tool_use ids were found without tool_result blocks immediately after.
The fix is small: keep tool-call and tool-result paired during the split (treat both as "tool" parts).
Operating System
macOS 26.0.1 / 25.4.0 (Apple Silicon).
Description
In
packages/opencode/src/provider/transform.ts,normalizeMessages()splits assistant turns where text trailstool-callblocks for Anthropic / Vertex Anthropic models. The current split filter groups onlytool-callparts together and treatstool-resultas non-tool content, so an assistant turn shaped like:becomes:
After provider/SDK merge this still presents
tool_useblocks without a pairedtool_resultimmediately after, so Anthropic returns:OpenCode version
1.14.33 (also reproduces against current
dev).Steps to reproduce
contentends up shaped like[tool-call, tool-result, text]or[tool-call, text, tool-result](this can happen during reconstruction or whentool-resultis co-located with the originatingtool-call).normalizeMessages().tool_use ids were found without tool_result blocks immediately after.The fix is small: keep
tool-callandtool-resultpaired during the split (treat both as "tool" parts).Operating System
macOS 26.0.1 / 25.4.0 (Apple Silicon).