/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'. (request id: 20250903110948261917640BBDOPt2p)
译文:函数“self_intent_recognition_0”的 schema 无效:None 不是“array”类型。(请求ID: 20250903110948261917640BBDOPt2p)
2.原因分析
self_intent_recognition_0的参数 schema 中,某字段预期为array类型,但实际传入了None。 invalid_function_parameters错误)。3. 解决方案
以 Python 定义 function schema 为例,修正字段类型为
array并避免None:from openai import OpenAI
import json
client = OpenAI()
# 修复后的 function 定义(确保目标字段为 array 类型)
tools = [
{
"type": "function",
"function": {
"name": "self_intent_recognition_0",
"description": "意图识别函数",
"parameters": {
"type": "object",
"properties": {
# 原错误字段(假设为"intents"):从 None 改为 array
"intents": {
"type": "array",
"items": {"type": "string"}, # 数组元素类型示例
"description": "意图列表(必传非空数组)"
}
},
"required": ["intents"] # 标记为必填,避免 None
}
}
}
]
# 调用时需传入合法 array(示例)
response = client.chat.completions.create(
model="gpt-4o",
messages=[{"role": "user", "content": "测试意图"}],
tools=tools,
tool_choice={"type": "function", "function": {"name": "self_intent_recognition_0"}}
)
4. 预防措施
jsonschema库)提前校验 function schema,确保字段类型与预期一致。 if not isinstance(param, list): raise ValueError),避免传入None或非 array 值。 ---
若有其他报错,请补充具体信息。