Error code: 400 - {'error': {'message': 'No tool call found for tool output with...

2026年09月18日 20:44 10.81 秒 success

错误信息

LLM 响应错误: All chat models failed: BadRequestError: Error code: 400 - {'error': {'message': 'No tool call found for tool output with call_id call_00_ET_Z7HheTqrBdPFqp972S8x5444.', 'type': 'invalid_request_error', 'param': None, 'code': 'invalid_request_error'}}

AI 解决方案

原文:No tool call found for tool output with call_id call_00_ET_Z7HheTqrBdPFqp972S8x5444.
译文:未找到与调用ID call_00_ET_Z7HheTqrBdPFqp972S8x5444 对应的工具调用记录。

🎯 原因分析


该错误表明在处理工具输出时,系统无法匹配到对应的工具调用请求。具体原因可能是:
  • 工具调用ID(call_id)与服务端记录不匹配

  • 工具调用流程中存在异步处理延迟或状态不一致

  • 工具调用请求已过期或被意外清除
  • 💡 解决方案


    检查并修复工具调用的完整流程,确保 call_id 正确传递和关联:

    # 修复示例(以Python为例)
    # 确保工具输出与原始请求的call_id一致
    tool_output = {
        "call_id": "call_00_ET_Z7HheTqrBdPFqp972S8x5444",  # 必须与请求中的call_id完全匹配
        "output": "工具执行结果"
    }
    
    # 完整工具调用流程
    try:
        # 1. 发起工具调用请求,保存返回的call_id
        tool_call = model.invoke(tools=[your_tool])
        call_id = tool_call.id  # 保存服务端返回的call_id
    
        # 2. 执行工具并返回结果,必须使用相同的call_id
        tool_result = your_tool_function(...)
        response = model.invoke(
            messages=[{
                "role": "tool",
                "tool_call_id": call_id,  # 严格匹配call_id
                "content": str(tool_result)
            }]
        )
    except Exception as e:
        print(f"工具调用失败: {e}")
    

    🛡️ 预防措施


  • 🔧 状态同步:在工具调用链路中添加状态校验机制,确保 call_id 等关键参数在请求和响应间完全一致

  • 📚 日志追踪:使用链路追踪工具(如OpenTelemetry)记录每个工具调用的请求/响应流程,便于定位ID不匹配问题