/MainProcess] 22208184909825/agent-e80a0 agent invoke chat to retry again llm er...

2026年04月15日 11:44 processing

错误信息

[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”的架构无效:None不是“array”类型

2. 原因分析


  • 根本原因:函数self_intent_recognition_0的参数Schema中,某应定义为数组(array)的字段被错误设置为None

  • 发生位置:该函数的JSON Schema定义(用于LLM函数调用),上下文是调用OpenAI API时触发参数验证失败。
  • 3. 解决方案


    修正函数Schema,将错误字段的类型从None改为array(需匹配实际数据结构):
    {
      "name": "self_intent_recognition_0",
      "description": "意图识别函数(示例描述)",
      "parameters": {
        "type": "object",
        "properties": {
          // 假设原错误字段是"candidate_intents"(需替换为实际字段名)
          "candidate_intents": { 
            "type": "array",       // 修复:将None改为array
            "items": { "type": "string" },  // 数组元素类型(按需调整)
            "description": "候选意图列表"
          }
        },
        "required": ["candidate_intents"]
      }
    }
    

    4. 预防措施


  • 定义函数Schema时,严格遵循OpenAI JSON Schema规范,用工具(如[AJV](https://ajv.js.org/))提前校验类型正确性。

  • 对数组类型字段,显式指定items子属性(避免隐式错误),并在代码中添加Schema版本检查。
  • ---
    请验证修复后的Schema是否匹配业务需求,若仍有问题请提供完整Schema片段。