【Bug已解决】Anthropic tool_result 找不到对应 tool use id 解决方案
1. 问题描述
在自己动手用 Anthropic Messages API 搭建 Agent Harness、实现多轮工具调用循环时,很多人会在某一次请求时遇到这样的 400 错误:
{
"type": "error",
"error": {
"type": "invalid_request_error",
"message": "messages.3: `tool_result` block(s) provided for tool use ids that were not found: toolu_01A2B3C4D5. Each `tool_result` block must have a corresponding `tool_use` block in the previous message."
}
}
有些场景下会看到相反方向的报错——工具调用有了,但结果没跟上:
Error: tool_use ids were found without tool_result blocks immediately after: toolu_01XYZ...
Each tool call in a message must have a corresponding tool_result in the next message.
用一些第三方框架(如部分基于 Anthropic SDK 二次封装的 Agent 框架)
订阅专栏 解锁全文
885





被折叠的 条评论
为什么被折叠?



