CC Switch local proxy failed while handling Codex endpoint /responses. Provider:...

2026年07月17日 13:52 26.55 秒 success

错误信息

CC Switch local proxy failed while handling Codex endpoint /responses. Provider: DeepSeek; model: deepseek-v4-flash; upstream_status: HTTP 400; cause: Invalid schema for function 'codex_app__automation_update': schema must be a JSON Schema of 'type: "object"', got 'type: null'.

AI 解决方案

🔍 错误分析

1. 🌐 错误翻译


原文:CC Switch local proxy failed while handling Codex endpoint /responses. Provider: DeepSeek; model: deepseek-v4-flash; upstream_status: HTTP 400; cause: Invalid schema for function 'codex_app__automation_update': schema must be a JSON Schema of 'type: "object"', got 'type: null'.
译文:CC Switch本地代理在处理Codex端点/responses时失败。提供商:DeepSeek;模型:deepseek-v4-flash;上游状态:HTTP 400;原因:函数'codex_app__automation_update'的schema无效:schema必须是'type: "object"'的JSON Schema,但得到的是'type: null'。

2. 🎯 原因分析


  • 根本原因:函数codex_app__automation_update的JSON Schema中,type字段被设置为null,而API要求type必须是"object"

  • 错误位置:在调用DeepSeek的Codex端点时,传入的函数定义参数格式不符合要求

  • 上下文:HTTP 400表示客户端请求错误,说明发送到上游服务的数据格式有问题
  • 3. 💡 解决方案


    检查并修复函数schema定义,确保type字段正确设置为"object"

    {
      "name": "codex_app__automation_update",
      "description": "自动化更新函数",
      "parameters": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "description": "记录ID"
          },
          "status": {
            "type": "string",
            "description": "状态"
          }
        },
        "required": ["id", "status"]
      }
    }
    

    如果你的代码中使用了函数调用相关参数,确保类似这样的定义正确:

    // 修复后的正确调用示例
    const functionCall = {
      name: 'codex_app__automation_update',
      arguments: {
        id: '123',
        status: 'active'
      },
      // 函数定义部分
      functionDef: {
        type: 'object',  // 必须明确指定
        properties: {
          id: { type: 'string' },
          status: { type: 'string' }
        },
        required: ['id', 'status']
      }
    };
    

    4. 🛡️ 预防措施


  • JSON Schema严格校验:在发送请求前,使用JSON Schema验证工具对函数定义进行校验,确保所有必填字段和格式符合要求

  • 类型检查:在构建schema时,显式声明type字段,避免使用null或未定义值,推荐使用TypeScript或JSDoc增强类型安全

  • 开发工具推荐:使用[JSON Schema Validator](https://json-schema.org/)在线工具或集成到IDE中的JSON Schema检查插件,实时发现格式问题