Skip to content

fix: merge consecutive tool results for Anthropic API compatibility#378

Open
glod wants to merge 1 commit intorowboatlabs:mainfrom
glod:fix/anthropic-parallel-tool-results
Open

fix: merge consecutive tool results for Anthropic API compatibility#378
glod wants to merge 1 commit intorowboatlabs:mainfrom
glod:fix/anthropic-parallel-tool-results

Conversation

@glod
Copy link

@glod glod commented Feb 17, 2026

Summary

  • Fixes parallel tool call failures when using Anthropic API
  • Merges consecutive tool result messages into a single message with all tool_result content blocks

Problem

When an agent workflow triggers multiple parallel tool calls, the Anthropic API returns an error:

"tool_use ids were found without tool_result blocks immediately after"

This happens because each tool result was being sent as a separate message, but Anthropic's API requires all tool results for parallel calls to be in a single message.

Solution

Modified convertFromMessages() in runtime.ts to detect consecutive tool messages and merge them into one message containing all tool_result blocks.

Fixes #375

When the Anthropic API returns multiple parallel tool calls in a single
assistant message, all tool_result blocks must be sent together in the
next message. Previously, each tool result was sent as a separate message,
causing Anthropic's API to reject the request with:
"tool_use ids were found without tool_result blocks immediately after"

This change modifies convertFromMessages() to merge consecutive tool
messages into a single message containing all tool_result content blocks.

Fixes rowboatlabs#375
@vercel
Copy link

vercel bot commented Feb 17, 2026

@glod is attempting to deploy a commit to the RowBoat Labs Team on Vercel.

A member of the Team first needs to authorize it.

@ramnique
Copy link
Contributor

I believe the Anthropic issue has been solved with this commit: 097efb3

If this is still an issue, can you put provide to reproduce (e.g. what prompt was used)?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

AI_APICallError - tool_use blocks without corresponding tool_result

2 participants