Bedrock Runtime: InvokeModel, https response error StatusCode: 400, RequestID: d...

2025年12月09日 22:24 状态: processing

🚨 错误信息

InvokeModel: operation error Bedrock Runtime: InvokeModel, https response error StatusCode: 400, RequestID: d86acb01-0221-4f80-9a44-9cb84190bfde, ValidationException: tools.0: Input tag 'function' found using 'type' does not match any of the expected tags: 'bash_20250124', 'custom', 'text_editor_20250124', 'text_editor_20250429', 'text_editor_20250728' (request id: 20251209222318520719231jTxxfBSw) (request id: 20251209222308497447090nUzSwJYj) (request id: 202512092223084301757991cnaSvhr) (request id: 20251209222211553314405u3WPQL73)

🤖 AI解决方案

错误翻译

原文:ValidationException: tools.0: Input tag 'function' found using 'type' does not match any of the expected tags: 'bash_20250124', 'custom', 'text_editor_20250124', 'text_editor_20250429', 'text_editor_20250728'
译文:验证异常:使用'type'找到的输入标签'function'与任何预期标签都不匹配:'bash_20250124'、'custom'、'text_editor_20250124'、'text_editor_20250429'、'text_editor_20250728'

原因分析

这是一个AWS Bedrock API调用时的工具类型验证错误。在请求中指定了工具类型为'function',但Bedrock Runtime只支持特定的工具类型,包括各种版本的文本编辑器和bash工具。

解决方案

{
  "tools": [
    {
      "toolSpec": {
        "name": "你想要使用的工具名称",
        "description": "工具描述",
        "inputSchema": {
          "json": {
            "type": "object",
            "properties": {
              // 具体属性定义
            },
            "required": ["必需参数"]
          }
        }
      }
    }
  ]
}

具体修复步骤:

  • 检查你的Bedrock API请求中的tools配置

  • 将工具类型改为支持的选项之一:

  • - text_editor_20250124
    - text_editor_20250429
    - text_editor_20250728
    - bash_20250124
    - custom

    ️ 预防措施

  • 查阅官方文档:在使用Bedrock API前,务必查看AWS官方文档中支持的参数和工具类型
  • 使用SDK验证:利用AWS SDK的类型检查功能,在开发阶段捕获此类配置错误
  • 版本兼容性检查:定期更新SDK并检查API版本兼容性,避免使用已废弃的参数