AI 开发

OpenAI DevDay 2026 后 Structured Output 和 Tool Calling 改了什么?2026 该用 Decisions 还是 text.format

阅读约 13 分钟

DevDay 没有发一个「新版 JSON Schema 产品」。官方 recap 的主线是 Decisions 与带 Computer use 的 Agents API。2026-10-22 Decisions 正式可用后,文档写得很硬:有界答案用 Decisions;要生成符合你 schema 的对象,用 Responses 的 text.format;要模型请求副作用,用 function calling。本文只写这三份 JSON 怎么分,不重讲 workflow 分层,也不改写 keynote 前的预测稿。

阅读前速览

能力 DevDay 后官方位置 返回什么
Structured Output Responses:text.format.type=json_schema;不是新 API 符合 schema 的对象(提取字段、给 UI 的结构)
Tool Calling Responses:扁平 tools[];output 项 function_call name + arguments 字符串;宿主执行
有界决策 POST /v1/decisions;10-22 GA,可带 input_json answers:predicate / choice / score,不执行工具
Agent 循环 Decisions 路由 → Responses 调工具 → 宿主 state choice 进 facts;Call/Result 仍是 Responses
Programmatic Tool Calling GPT-5.6 起就有;DevDay 课表提到,不是 Structured Output 替代品 程序在托管 V8 里调 allowed_callers 工具

事实截至 2026-10-30:DevDay recap、Decisions GA 博文与指南、Responses 迁移 / Structured Outputs / Function calling 文档。A-1042、T-8841、resp_8k1a 为虚构。

改的是分路,不是「更好的 JSON mode」

keynote 前很多人把 Structured Output、Tool Calling、Agent Workflow 写成同一件事:给模型一份大 schema,让它既路由又抽字段又调工具。官方 2026 文档把三件事拆开:

  • Structured Output 仍是 Responses。Chat Completions 的 response_format 迁到 text.format。DevDay recap 没有把它列为当天新品。
  • Tool Calling 在 Responses 里变成扁平 type/name/parameters;写回用 function_call_output 对齐 call_id。省略 strict 时 Responses 会尝试规范化,失败则回落到 strict: false。
  • 有界路由 走 Decisions。10-22 GA 增加原生 JSON 证据(input_json)、最多 400 题、可把 function_call 历史当证据。返回的是 typed answers,不是你自定义的业务对象。

当天发了什么见 DevDay 实发;三层怎么串见 Workflow 实测;旧字段怎么改见 API 迁移。

旧请求形状 vs text.format vs 扁平工具 vs Decisions

1. 不要再把路由、抽取、工具挤进同一份 Chat Completions 请求。 下面是仍常见、但已不是 DevDay 后主路径的形状:

{
  "model": "gpt-4o",
  "messages": [
    {"role": "user", "content": "Extract order A-1042 as JSON."}
  ],
  "response_format": {
    "type": "json_schema",
    "json_schema": {
      "name": "order_extract",
      "strict": true,
      "schema": {
        "type": "object",
        "properties": {
          "order_id": { "type": "string" },
          "status": { "type": "string" }
        },
        "required": ["order_id", "status"],
        "additionalProperties": false
      }
    }
  },
  "tools": [{
    "type": "function",
    "function": {
      "name": "lookup_order",
      "parameters": { "type": "object" }
    }
  }]
}

2. 要生成符合 schema 的对象:Responses + text.format。 官方指南:连工具用 function calling;给用户/下游一份结构对象用 text.format。

{
  "model": "gpt-6-astra",
  "input": "Jane paid order A-1042.",
  "text": {
    "format": {
      "type": "json_schema",
      "name": "order_extract",
      "strict": true,
      "schema": {
        "type": "object",
        "properties": {
          "order_id": { "type": "string", "pattern": "^[A-Z]-\\d{4}$" },
          "status": { "type": "string", "enum": ["paid", "open"] }
        },
        "required": ["order_id", "status"],
        "additionalProperties": false
      }
    }
  }
}

3. 要副作用:扁平 tools,arguments 先校验再执行。 续聊带 previous_response_id,不要把 Decisions 的 answers 整包 stringify 进 prompt。

{
  "model": "gpt-6-luna",
  "previous_response_id": "resp_8k1a",
  "tools": [{
    "type": "function",
    "name": "lookup_order",
    "strict": true,
    "parameters": {
      "type": "object",
      "properties": {
        "order_id": { "type": "string", "pattern": "^[A-Z]-\\d{4}$" }
      },
      "required": ["order_id"],
      "additionalProperties": false
    }
  }],
  "input": [{
    "role": "user",
    "content": [{ "type": "input_text", "text": "Look up A-1042 if needed." }]
  }]
}

4. 要分类/路由:Decisions + input_json。 data 里的键不会变成消息或去拉图;答案类型仍是你声明的 question type。

{
  "model": "gpt-6-luna",
  "input": [{
    "role": "user",
    "content": [
      { "type": "input_text", "text": "Route using the ticket and order." },
      {
        "type": "input_json",
        "data": {
          "ticket": { "body": "Please refund the duplicate charge." },
          "order": { "order_id": "A-1042", "charges": [49, 49] }
        }
      }
    ]
  }],
  "questions": [{
    "type": "choice",
    "name": "route",
    "instructions": "Pick the next host action. Do not call tools.",
    "choices": [
      { "value": "lookup", "description": "Call lookup_order" },
      { "value": "hold", "description": "Stop for a human" }
    ]
  }]
}

三路对照:生成对象、请求工具、有界答案

把「JSON」当成一个产品名会选错 API。按返回合同选:

你需要 用哪个 API 不要用
抽取字段 / 给 UI 的对象 Responses text.format json_schema Decisions answers 或 json_object 模式充 schema
查库、退款、写文件 Responses function tools(strict + additionalProperties:false) 让 Decisions 去执行 lookup
部门路由 / 是否重复扣费 Decisions choice 或 predicate 用大 json_schema 生成 next_action 散文
多步聚合、过滤工具结果 programmatic_tool_calling + allowed_callers 把它当成新的 Structured Output
长任务托管循环 Agents API(含 Computer use) 用 Chat Completions messages 冒充 session

Programmatic Tool Calling 让模型写一段在隔离 V8 里跑的 JavaScript 去协调工具;应用仍要执行客户端工具。它解决的是控制流,不是「输出必须符合我的业务 schema」。

从旧 Chat Completions 迁到分路

staging 用虚构订单跑通后再接生产票:

  1. 列出三种输出。对象 / 工具参数 / 有界枚举,各写一份 schema 或 choices 列表。
  2. 对象路径改 text.format。删掉 Responses 请求里的 response_format。
  3. 工具改扁平定义。补 additionalProperties:false 与 required;需要非严格时显式 strict:false。
  4. 路由改 Decisions。证据用 input_json;choice 写入宿主 facts,再发 Responses 工具请求。
  5. 写回对齐 call_id。不要用旧的 role:tool 消息形状。

Agents 托管路径把 Call/Result 换成 session 事件,但「Decisions 不执行工具」这条不变。

把 schema、arguments、answers 摊开看

90% 的「模型乱输出 JSON」是把三路混在一次请求里,不是 Luna 不会填字段。

  • 用 格式化 展开 arguments 与 text.format 结果;用 Schema 校验 校验工具 parameters 与抽取 schema。
  • 用 JSON Diff 对比迁移前后请求:response_format 是否还在、tools 是否仍套 function 一层。
  • 用 JSONPath 从 Decisions answers 取 name=route 的 choice,确认没有当成 order 对象。
  • 五段循环字段见 Agent JSON State。
  • JSONSort 本地处理;不要上传真实工单或密钥。

三份 JSON 能分别通过 Schema,你才算迁完,而不是「看起来都是 JSON」。

常见误区

  • 以为 DevDay 发了新 Structured Outputs API。recap 没列;能力仍在 Responses。
  • 用 Decisions 生成订单对象。answers 只有 probability / choice / score。
  • Responses 里继续写 response_format。迁移指南明确改 text.format。
  • 工具仍套 function.function 两层。Responses 是内部 tagged 扁平形状。
  • 省略 strict 却假定永远严格。schema 不兼容时会回落到 strict:false。
  • 把 Programmatic Tool Calling 当 schema 门。它协调调用;业务对象仍要 text.format 或宿主校验。

FAQ

json_object 模式还能用吗?

能产出合法 JSON,但不保证符合你的 schema。能走 json_schema 的 text.format 就不要退回 json_object。

Decisions 的 input_json 会替代 Structured Output 吗?

不会。input_json 是证据;答案形状仍由 question type 决定,不会变成你自定义的对象。

Chat Completions 的 function 定义要立刻删吗?

继续用 Completions 可以暂时保留外层 function 包装;一旦切 Responses,按迁移指南改扁平定义与 call_id 写回。

和 Workflow / State 两篇有何区别?

那两篇讲怎么串循环、怎么存宿主 state。本篇只回答:三份 JSON 合同分别落在哪个官方 API。

Programmatic Tool Calling 是 DevDay 新品吗?

文档把它标在 GPT-5.6 工具指南;DevDay 课表「Stop Overpaying」提到它。不要写成 9 月 29 日才出现的 Structured Output。

结论

DevDay 2026 之后,Structured Output 和 Tool Calling 没有合并成一个更大的 schema:对象走 text.format,副作用走扁平 function,有界选择题走 Decisions。10 月 22 日 GA 只是把路由这条路修硬了,不是让 Decisions 去生成业务 JSON。

先画三张合同,再改字段名。模型仍然只填 JSON;执行和下一跳永远是宿主的事。

延伸阅读

更新记录: 首次发布