AI 开发

OpenAI DevDay 2026 后 AI Agent 怎么搭 Workflow?2026 Decisions API、JSON Tools 与 Structured Data 实测

阅读约 15 分钟

9 月 29 日 DevDay 定的是分工:10 月 22 日 Decisions API 正式 GA,支持原生 input_json 与最多 400 个问题。长对话与工具循环仍走 Responses / Agents;模型只产 JSON,宿主按 decision → tool → structured 顺序执行。

阅读前速览

层 2026 官方能力 宿主做什么
路由 / 分类 POST /v1/decisions,gpt-6-luna;predicate / choice / score;input_json 传 ticket + order 把 choice 映射到下一 API,不在这里调工具
工具与副作用 Responses function_call + function_call_output;Agents API 托管 Computer Use / 多 agent Schema 校验 arguments,执行 lookup_order,写回 call_id
Structured 输出 Responses text.format json_schema 或工具结果再摘要;customer_visible 字段由宿主保存 与 tool result 分开存,避免把原始 API 响应直接展示
状态 workflow_id、response_id、last_decision;async 工具用 pending_async 列表 previous_response_id 续聊,不要手写丢 reasoning 项

事实截至 2026-10-26:Decisions GA(changelog)、Decisions 指南 input_json、DevDay 2026 recap。A-1042、T-8841、wf_demo_3a 为虚构。

Workflow 变成「先决策、再工具、最后结构化交付」

DevDay 之前很多团队把分类、查单、生成回复塞进同一次 Chat Completions 循环。DevDay 之后官方路径更清晰:bounded 问题走 Decisions(文档称可比同模型 Responses 快约 10×);需要副作用的 lookup_order 仍在 Responses;要长期任务、浏览器或子 agent 再上 Agents API。2026 年 10 月 GA 的 Decisions 允许在 user 消息里放 input_json,不必先把工单对象 stringify 进 prompt——这直接改变你 pipeline 里「上下文 JSON」放哪一层。

  • Decisions:返回 choice / probability / score,适合 route、risk gate、是否 escalate。
  • Responses tools:function_call 执行真实查询;structured output 约束最终给用户看的 JSON。
  • Agents API:Harness、Computer Use、tool search 由 OpenAI 托管;你的应用仍要定义 state 写回。

发布了什么见 DevDay 发布清单;字段迁移见 API 迁移;Responses 与 Agents 选型见 Agents 与 Responses。本篇是实测工作流,不重讲 JSON Schema 是什么。

Decision → Tool → Output → State

第一步:把结构化证据放进 Decisions,而不是长 prompt。官方示例用 input_json 的 data 承载 ticket 与 order:

{
  "model": "gpt-6-luna",
  "input": [{
    "role": "user",
    "content": [
      { "type": "input_text", "text": "Route this ticket using the order record." },
      { "type": "input_json", "data": {
          "ticket": { "id": "T-8841", "topic": "billing" },
          "order": { "order_id": "A-1042", "status": "paid" }
      }}
    ]
  }],
  "questions": [{
    "type": "choice",
    "name": "route",
    "instructions": "Pick the next host action. Do not call tools here.",
    "choices": [
      { "value": "lookup", "description": "Call lookup_order" },
      { "value": "hold", "description": "Stop and wait" },
      { "value": "escalate", "description": "Hand to a person" }
    ]
  }]
}

第二步:仅当 route 为 lookup 时,才在 Responses 请求里注册工具。strict 写明,宿主仍校验:

{
  "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
  }
}

第三步:模型返回 function_call。解析 arguments 字符串,执行后按 call_id 写回:

{
  "type": "function_call",
  "call_id": "call_3c91",
  "name": "lookup_order",
  "arguments": "{\"order_id\":\"A-1042\"}"
}

第四步:function_call_output 可再接一轮 Responses,用 json_schema 生成对用户可见的摘要字段:

{
  "type": "function_call_output",
  "call_id": "call_3c91",
  "output": "{\"order_id\":\"A-1042\",\"status\":\"paid\",\"amount\":99.00}"
}

宿主用一份 workflow state 把 decision、response_id 与 structured 字段绑在一起,下一轮不必让模型重猜 route:

{
  "workflow_id": "wf_demo_3a",
  "step": "after_tool",
  "last_decision": { "name": "route", "choice": "lookup" },
  "response_id": "resp_9f2b",
  "pending_async": [],
  "structured": { "customer_visible": "Your order A-1042 is paid." }
}

同一任务里四个 API 面,不要混解析器

选错入口会把 latency 和成本叠在一起。按官方边界拆:

你要什么 用哪个面
从固定集合选下一步(lookup / hold / escalate) Decisions choice;可用 input_json + 缓存共享上下文
调 REST、查库、改记录 Responses function_call;慢工具用 async: true + 原 call_id 回写
多步浏览、子 agent、Computer Use Agents API;回写 turn_id,不是 function_call_output 形状
给用户 / 下游系统的 JSON 合同 Responses structured output 或宿主从 tool result 映射到 schema

OpenAI 在 10 月 22 日的 Decisions 博文举了 Box 路由文档、Datadog 在热路径评分 shell 风险等案例——共同点是决策 JSON 与执行 JSON 分离。不要把 Decisions 的 choice 当成已经执行了 lookup。

从 0 搭一条可测 workflow 的六步

建议先在 staging 用虚构订单跑通 JSON diff,再切生产模型 ID:

  1. 画出状态机。哪些 transition 只改枚举(Decisions),哪些会调工具(Responses)。
  2. 定义 input_json 合同。ticket / order 字段名固定;与 CRM 导出 JSON 对齐,便于 JSONPath 抽取。
  3. 注册工具与 strict。一个副作用一个 function;arguments 过 Schema 再执行。
  4. 映射 choice → 动作。lookup → 发起 Responses 并带 order_id;escalate → 写队列,不调用 lookup_order。
  5. 分离 raw 与 visible。tool output 存全量;structured.customer_visible 只含允许展示的字段。
  6. 记录 response_id 与 decision。续聊用 previous_response_id;审计时 Diff 每跳 JSON。

需要迁移旧 Chat Completions 循环时,先改字段形状再改模型名——顺序见迁移文,不要与本篇步骤对调。

上线前摊开三类 JSON

常见 bug 是 choice 已 escalate 却仍发出 function_call,或 structured 字段混入未脱敏的 tool output。

  • 用 格式化 展开 arguments;用 Schema 校验 校验 tool 与 structured 两份 schema。
  • 用 JSON Diff 对比 Decisions 请求前后、tool output 与 customer_visible 的差异。
  • 用 JSONPath 从 input_json 抽 $.order.order_id,与 function_call arguments 对齐。
  • 确认 Decisions 响应里 refusal 时不触发工具链。
  • JSONSort 本地处理调试 JSON;不要贴生产 PII 或密钥。

三类 JSON 对齐后,workflow 才是你定义的状态机,而不是模型即兴串 API。

常见误区

  • 用 Responses 做纯路由。能用 choice 的跳不要浪费整轮 tool 定义与 reasoning token。
  • 在 Decisions 里假装调工具。questions 只返回答案;执行必须在宿主。
  • 把 input_json 当 log 随便扩字段。未在 schema 里约定的字段会让路由漂移;先定合同再扩。
  • structured 与 tool output 共用一个对象。用户可见 JSON 应更小、更稳定。
  • Agents 与 Responses 混用 call_id。两种回写形状不同,不要共用一个解析器。
  • 忽略 async 回写顺序。慢工具提交 output 前不要重复发同名 function_call。

FAQ

Decisions GA 后还要用 Chat Completions 做路由吗?

新路由建议走 Decisions + gpt-6-luna。旧 Completions 循环仍可迁 Responses(见迁移文),但热路径分类优先 Decisions。

input_json 和把 JSON stringify 进 prompt 有何区别?

官方把结构化对象放在 content part 的 data 里,模型与缓存按结构化证据处理;少一层转义错误,也便于与 ticket 系统字段一一对应。

Structured output 能替代 function_call 吗?

不能。Structured output 约束模型生成的 JSON;查单等副作用仍要 function_call + 宿主执行。

Agents API 是否包含 Decisions?

产品面分开。Agents 托管长任务与 Computer Use;编排里仍可在调用 Agents 之前单独打 Decisions 做 gate。

400 questions 限制对谁有影响?

批量质检、日志标注类工作流可把多问题塞进一次 Decisions;普通客服路由通常 1–3 个 choice 即可。

结论

DevDay 2026 之后的 Agent workflow,实质是把 JSON 按职责分层:Decisions 处理 bounded 路由与评分,Responses 处理 tools 与 structured 交付,Agents 处理托管长任务。10 月 GA 的 input_json 让「上下文 JSON」从 prompt 字符串里解放出来。

搭新 flow 时先画状态机,再填四段 JSON 模板。模型仍只填字段;是否查单、是否展示给用户,永远是宿主的 decision。

延伸阅读

更新记录: 首次发布