/MainProcess] 22208184909825/agent-e80a0 agent invoke chat to retry again llm er...
错误信息
[2025-09-03 11:10:25,969: ERROR/MainProcess] 22208184909825/agent-e80a0 agent invoke chat to retry again llm error: Error code: 400 - {'error': {'message': "Invalid schema for function 'self_intent_recognition_0': None is not of type 'array'. (request id: 20250903110948261917640BBDOPt2p)", 'type': 'openai_error', 'param': '', 'code': 'invalid_function_parameters'}}
AI 解决方案
报错分析报告
1.错误翻译
原文:Invalid schema for function 'self_intent_recognition_0': None is not of type 'array'
译文:函数'self_intent_recognition_0'的 schema 无效:None 不是 'array' 类型
2.原因分析
self_intent_recognition_0的参数 schema 中,某字段预期为array类型,但实际传入了None。 3. 解决方案
以 OpenAI Function Calling 为例,修复 schema 或调用参数:
# 修复1:调整函数Schema,为array参数设默认值(避免None)
functions = [
{
"name": "self_intent_recognition_0",
"parameters": {
"type": "object",
"properties": {
"target_array": { # 问题字段(原传None)
"type": "array",
"items": {"type": "string"},
"default": [] # 设为空数组默认值
}
},
"required": ["target_array"]
}
}
]
# 修复2:调用时确保传入array(而非None)
function_args = {"target_array": []} # 或实际数组数据,如["item1", "item2"]}
4. 预防措施
[]),禁止None。 pydantic、TypeScript 的zod)验证参数类型。 推荐工具:pydantic(自动校验模型参数)、OpenAI 官方 [Function Schema Validator](https://platform.openai.com/docs/guides/functions)。