找出工具续接里的 bug

来自 Claude API
Claude Developer Platform (2026-09) 进阶 4分钟 找出 2处问题

找出这段生成的工具续接代码中的协议错误。

Python
def continue_tool(response, messages):
    call = response["content"][0]
    output = run_tool(call["name"], call["input"])
    messages.append({
        "role": "user",
        "content": [{
            "type": "tool_result",
            "tool_use_id": call["id"],
            "content": output,
        }],
    })
    return messages
在试验场中打开
报告错误