Skip to content

Tools schema 中 oneOf 导致的 type 错误问题 #403

@mihucho

Description

@mihucho

Describe the bug
在使用 tools 时遇到 schema 类型定义错误。当 schema 涉及到 oneOf 时,根节点没有 type 属性导致报错,而手动添加 type 后又因为不允许在顶级使用 oneOf 而报错。

To Reproduce
重现步骤:

  1. 创建一个包含 oneOf 的 tools schema
  2. 不添加根节点 type 属性
  3. 执行时看到错误:Invalid schema for function 'generate_data': schema must be a JSON Schema of 'type: "object"', got 'type: null'.
  4. 尝试添加 type: "object" 到根节点
  5. 看到新的错误:schema must have type 'object' and not have 'oneOf'/'anyOf'/'allOf'/'enum'/'not' at the top level.

Screenshots
暂无截图

Tools or Programming Language
使用 GPT tools 功能,涉及 JSON Schema 定义。具体是在定义 function schema 时遇到的问题,schema 中使用了 oneOf 来定义多种可能的对象类型。

Additional context
这个问题表明当前的 tools schema 验证机制存在冲突:

  • 系统要求根节点必须有 type: "object"
  • 但同时又不允许在顶级使用 oneOf/anyOf/allOf 等 JSON Schema 关键字
  • 这使得无法正确定义包含 oneOf 的复杂 schema 结构

而前几天还没有这个问题,是加强校验了吗?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions