tools..input_schema: input_schema does not support oneOf at the top level (reque...
错误信息
tools..input_schema: input_schema does not support oneOf at the top level (request id: 202610281532231076995248268d9d6hFw0u3O4)
AI 解决方案
🔍 报错分析
1. 🌐 错误翻译
原文:tools..input_schema: input_schema does not support oneOf at the top level (request id: 202610281532231076995248268d9d6hFw0u3O4)
译文:tools..input_schema:input_schema 不支持在顶层使用 oneOf(请求 ID:202610281532231076995248268d9d6hFw0u3O4)
2. 🎯 原因分析
该错误通常出现在调用 LLM API 或定义工具参数时,在工具的
input_schema 顶层直接使用了 oneOf 结构。多数API规范要求工具参数 schema 必须符合 JSON Schema 标准,且顶层字段有严格限制,不支持直接用 oneOf 描述参数结构,需改用受支持的字段。3. 💡 解决方案
将
input_schema 顶层的 oneOf 替换为 API 规范支持的字段(如 properties 配合 anyOf,或拆分参数),以下为修复示例:// 修复前(错误写法)
{
"tools": [
{
"type": "function",
"function": {
"name": "example_tool",
"input_schema": {
"oneOf": [
{
"type": "object",
"properties": { "a": { "type": "string" } }
},
{
"type": "object",
"properties": { "b": { "type": "number" } }
}
]
}
}
}
]
}
// 修复后(正确写法)
{
"tools": [
{
"type": "function",
"function": {
"name": "example_tool",
"input_schema": {
"type": "object",
"properties": {
"a": { "type": "string" },
"b": { "type": "number" }
},
"anyOf": [
{ "required": ["a"] },
{ "required": ["b"] }
]
}
}
}
]
}
4. 🛡️ 预防措施
jsonschema、在线校验平台)提前验证 schema 合规性,避免部署后报错。