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

2026年04月14日 17:31 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'. (request id: 20250903110948261917640BBDOPt2p)
译文:函数'self_intent_recognition_0'的 schema 无效:None 不是 'array' 类型。(请求ID: 20250903110948261917640BBDOPt2p)

2.原因分析


  • 根本原因:函数self_intent_recognition_0的参数 schema 中,某字段预期类型为array,但实际定义/传入了None

  • 发生位置:函数schema定义(如参数类型标注错误)或调用时参数传递(传入None而非数组)。
  • 3. 解决方案


    修正函数schema的类型定义,确保目标字段为array类型;若调用传参,替换为有效数组(如空数组[])。
    JSON Schema为例(修复后):
    {
      "name": "self_intent_recognition_0",
      "parameters": {
        "type": "object",
        "properties": {
          // 假设原错误字段为"intents",需明确type为array
          "intents": {
            "type": "array",
            "items": { "type": "string" } // 按需调整元素类型
          }
        },
        "required": ["intents"]
      }
    }
    

    调用时确保传参:{"intents": []}(空数组)或有效数组值。

    4. 预防措施


  • ✅ 定义 function schema 时,严格遵循 JSON Schema 规范,用工具(如 [JSON Schema Validator](https://www.jsonschemavalidator.net/))预校验。

  • ✅ 调用函数前,检查参数类型:数组字段禁止传None,优先用空数组[]兜底。
  • ---
    分析完成,请验证修复效果。