***.***.custom.input_schema: input_schema does not support oneOf, allOf, or anyO...

2026年10月23日 12:07 13.44 秒 success

错误信息

***.***.custom.input_schema: input_schema does not support oneOf, allOf, or anyOf at the top level (request id: 202610230406504806296718268d9d6FnEOkdY5)

AI 解决方案

原文:***.***.custom.input_schema: input_schema does not support oneOf, allOf, or anyOf at the top level
译文:***.***.custom.input_schema:input_schema不支持在顶层使用oneOf、allOf或anyOf

🎯 原因分析


错误表明在定义input_schema时,在其顶层使用了oneOf、allOf或anyOf组合,而当前框架/规范不允许这种用法。这类组合关键字通常用于组合多个子模式,但平台对input_schema的顶层结构有严格限制,只支持单一对象或基本类型的模式定义。

💡 解决方案


将顶层的oneOf/allOf/anyOf结构展开为单一对象,或通过嵌套方式重构模式,确保顶层仅为普通对象:
// 修复前(错误示例,顶层使用了oneOf)
{
  "input_schema": {
    "oneOf": [
      {
        "type": "object",
        "properties": {
          "name": { "type": "string" }
        }
      },
      {
        "type": "object",
        "properties": {
          "age": { "type": "integer" }
        }
      }
    ]
  }
}

// 修复后(正确示例,顶层为单一对象,合并字段)
{
  "input_schema": {
    "type": "object",
    "properties": {
      "name": { "type": "string" },
      "age": { "type": "integer" }
    }
  }
}

🛡️ 预防措施


  • 规范约束:编写input_schema前,明确平台对Schema的顶层结构要求,避免直接使用组合关键字。

  • 工具校验:使用JSON Schema校验工具(如Swagger Editor、JSON Schema Linter)提前检查Schema合法性,提前发现问题。