fix: merge consecutive tool results for Anthropic API compatibility#378
Open
glod wants to merge 1 commit intorowboatlabs:mainfrom
Open
fix: merge consecutive tool results for Anthropic API compatibility#378glod wants to merge 1 commit intorowboatlabs:mainfrom
glod wants to merge 1 commit intorowboatlabs:mainfrom
Conversation
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
|
@glod is attempting to deploy a commit to the RowBoat Labs Team on Vercel. A member of the Team first needs to authorize it. |
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)? |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
tool_resultcontent blocksProblem
When an agent workflow triggers multiple parallel tool calls, the Anthropic API returns an error:
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()inruntime.tsto detect consecutive tool messages and merge them into one message containing alltool_resultblocks.Fixes #375