错误信息: Claude Code returned an error result: API Error: 400 {"error":{"type":"400...

2026年06月09日 00:08 37.28 秒 success

错误信息

错误名称: AI_ProviderSpecificError 错误信息: Claude Code returned an error result: API Error: 400 {"error":{"type":"400","message":"Invalid JSON payload received. Unknown name \"propertyNames\" at 'tools[0].function_declarations[9].***.properties[1].value': Cannot find field. (request id: 20260609000727318799035pYLT3R91)"},"type":"error"} 堆栈信息: AI_ProviderSpecificError: Claude Code returned an error result: API Error: 400 {"error":{"type":"400","message":"Invalid JSON payload received. Unknown name \"propertyNames\" at 'tools[0].function_declarations[9].***.properties[1].value': Cannot find field. (request id: 20260609000727318799035pYLT3R91)"},"type":"error"} at AiSdkToChunkAdapter.convertAndEmitChunk (file:///D:/Cherry-Studio/Cherry%20Studio/resources/app.asar/out/renderer/assets/store-D-J5UN_L.js:350233:64) at AiSdkToChunkAdapter.readFullStream (file:///D:/Cherry-Studio/Cherry%20Studio/resources/app.asar/out/renderer/assets/store-D-J5UN_L.js:350024:10) at async AiSdkToChunkAdapter.processStream (file:///D:/Cherry-Studio/Cherry%20Studio/resources/app.asar/out/renderer/assets/store-D-J5UN_L.js:349986:31) at async fetchAndProcessAgentResponseImpl (file:///D:/Cherry-Studio/Cherry%20Studio/resources/app.asar/out/renderer/assets/store-D-J5UN_L.js:168231:3) at async file:///D:/Cherry-Studio/Cherry%20Studio/resources/app.asar/out/renderer/assets/store-D-J5UN_L.js:168418:5 at async file:///D:/Cherry-Studio/Cherry%20Studio/resources/app.asar/out/renderer/assets/store-D-J5UN_L.js:143360:21 错误原因: { "message": "Claude Code returned an error result: API Error: 400 {\"error\":{\"type\":\"400\",\"message\":\"Invalid JSON payload received. Unknown name \\\"propertyNames\\\" at 'tools[0].function_declarations[9].***.properties[1].value': Cannot find field. (request id: 20260609000727318799035pYLT3R91)\"},\"type\":\"error\"}", "type": "stream_error", "code": "stream_processing_failed" }

AI 解决方案

🔍 错误分析

#### 1. 🌐 错误翻译

原文:Invalid JSON payload received. Unknown name "propertyNames" at 'tools[0].function_declarations[9].***.properties[1].value': Cannot find field.
译文:收到了无效的JSON负载。在 ‘tools[0].function_declarations[9].***.properties[1].value’ 路径下发现未知字段名 "propertyNames"。

#### 2. 🎯 原因分析

  • 根本原因:调用Claude API时,发送的请求体(JSON Payload)中包含了该API版本不支持的字段或格式。

  • 具体位置:错误明确指出问题出在 tools 参数下的 function_declarations 数组中的一个工具定义里。具体路径指向某个工具属性(properties)中的一个值(value),该位置使用了一个名为 propertyNames 的字段,但API无法识别。

  • 上下文分析propertyNames 通常是JSON Schema规范中的一个关键字。此错误表明,您使用的AI应用框架(Cherry Studio)或底层的AI SDK在构建工具调用请求时,可能使用了与Claude API当前版本要求不兼容的JSON Schema字段或结构。
  • #### 3. 💡 解决方案
    此问题通常需要修改发送给API的工具定义结构。您需要检查并修改生成工具定义的代码。

    1. 检查并修改工具定义:
    定位到构建 function_declarations 的代码,找到第10个工具定义(索引为9)。检查其中 properties 的定义,移除或替换不兼容的 propertyNames 字段。

    例如,将:

    {
      "name": "example_tool",
      "parameters": {
        "type": "object",
        "properties": {
          "my_property": {
            "type": "string",
            "propertyNames": { ... } // 移除此行
          }
        }
      }
    }
    

    修改为Claude API支持的标准格式,通常 propertyNames 并非必需,直接移除或使用其他方式(如 pattern)验证属性名。

    2. 更新AI SDK或应用框架:
    如果您正在使用Cherry Studio或某个AI SDK,检查是否有可用更新。开发者可能已在新版本中修复了此兼容性问题。

    #### 4. 🛡️ 预防措施

  • 查阅官方文档:在定义工具(Function Calling)时,务必参考 Claude API最新的官方文档,了解其支持的JSON Schema字段和格式要求。

  • 使用验证工具:在开发过程中,可以使用在线JSON Schema验证器,将您构建的工具定义JSON与官方示例进行对比,提前发现不兼容的字段。

  • 保持SDK更新:定期更新您使用的AI客户端库或应用框架,以确保其与目标API的兼容性。