mirror of
https://github.com/deepseek-ai/DeepSeek-V3.git
synced 2026-11-05 00:47:48 +00:00
[GH-ISSUE #967] [BUG] Anthropic API format throws and error on parallel tool use results // Anthropic API格式在并行工具使用结果上抛出错误) #586
Labels
No labels
closed-as-stale
enhancement
question
spam
stale
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
deepseek-ai/DeepSeek-V3#586
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @A0A on GitHub (Aug 26, 2025).
Original GitHub issue: https://github.com/deepseek-ai/DeepSeek-V3/issues/967
Describe the bug
Using the python Anthropic SDK, returning the results of parallel tool calls produces this error:
anthropic.BadRequestError: Error code: 400 - {'error': {'message': 'messages.3:tool_useids were found withouttool_resultblocks immediately after: call_1_809f60b6-1f6a-4c00-ac1f-decff9e93b43, call_2_5fd0c971-fbdd-4403-af08-9343b0ad7111. Eachtool_useblock must have a correspondingtool_resultblock in the next message.', 'type': 'invalid_request_error', 'param': None, 'code': 'invalid_request_error'}}Anthropic's message format contains an array of "blocks" in each message, and parallel tool calls arrive together as multiple blocks in that array. When the results of each tool call are sent back to the Deepseek API as blocks in a single array in the next tool call, the above error occurs. This error also occurs if tool call results are sent back in sequential messages, one per block.
To Reproduce
Expected behavior
I would expect the api to proceed with the conversation based on the content of the tool call results. I've verified that the exact same code works when used to invoke Anthropic platform with Claude Sonnet 4.
Screenshots
Not applicable
Additional context
None
由Deepseek v3.1从英文翻译为中文
问题描述
使用Python Anthropic SDK时,返回并行工具调用的结果会产生以下错误:
anthropic.BadRequestError: Error code: 400 - {'error': {'message': 'messages.3:tool_useids were found withouttool_resultblocks immediately after: call_1_809f60b6-1f6a-4c00-ac1f-decff9e93b43, call_2_5fd0c971-fbdd-4403-af08-9343b0ad7111. Eachtool_useblock must have a correspondingtool_resultblock in the next message.', 'type': 'invalid_request_error', 'param': None, 'code': 'invalid_request_error'}}Anthropic的消息格式在每个消息中包含一个"blocks"数组,并行工具调用会作为该数组中的多个块一起到达。当每个工具调用的结果作为单个数组中的块在下一次工具调用中发送回Deepseek API时,会出现上述错误。如果工具调用结果在一个块一个消息中顺序发送回,也会出现此错误。
重现步骤
预期行为
我期望API能根据工具调用结果的内容继续对话。我已经验证过完全相同的代码在调用Anthropic平台的Claude Sonnet 4时能够正常工作。
截图
不适用
附加信息
无
@onelife commented on GitHub (Aug 31, 2025):
I encountered the same issue with the following code snippet, which works with the Anthropic API.
I suppose the difference is that the Anthropic API only considers the last "tool use" block when parsing the last "tool result" block in context, whereas the DeepSeek API considers all "tool use" blocks and expects them to have corresponding "tool result" blocks.
The Anthropic API method reduces payload size and cost.
Hi @A0A, before this issue is fixed. You may change your code to add all "tool result" blocks into context as follows: the code snippet below works for me.
@A0A commented on GitHub (Aug 31, 2025):
Nice catch, thank you!
@github-actions[bot] commented on GitHub (Oct 2, 2025):
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. If you believe this issue is still relevant, please leave a comment to keep it open. Thank you for your contributions!
@github-actions[bot] commented on GitHub (Oct 17, 2025):
false