Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: anthropic parallel tool call results. #653

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

ioga
Copy link

@ioga ioga commented Jan 9, 2025

I've found that when receiving parallel tool results, Anthropic API requires the results to be grouped within the content field of a single message. If the client returns them as several role='user', content=[<TOOL_RESULT>] messages, Anthropic API will end up return an error like this:

anthropic.BadRequestError: Error code: 400 - {'type': 'error', 'error': {'type': 'invalid_request_error', 'message': "messages.2: the following `tool_use` ids were not found in `tool_result` blocks: {'toolu_01MtMyrsycEunT8wDfk2vpAi', 'toolu_01SzMGM1XsqzqYi9gNDWkV9P'}"}}

This is similar to #562 , but is specific to Anthropic as far I can tell.

This PR groups multiple tool results within a single ModelRequest into one message which addresses the issue for me.

@TeunvdWeij
Copy link

Would be great if this could be merged soon! Thanks for your efforts.

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.

2 participants