OpenAI DevDay 2026 後 AI Agent 怎麼搭 Workflow?2026 Decisions API、JSON Tools 與 Structured Data 實測
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:
- 畫出狀態機。哪些 transition 只改列舉(Decisions),哪些會調工具(Responses)。
- 定義 input_json 合約。ticket / order 欄位名固定;與 CRM 匯出 JSON 對齊,便於 JSONPath 抽取。
- 註冊工具與 strict。一個副作用一個 function;arguments 過 Schema 再執行。
- 對映 choice → 動作。lookup → 發起 Responses 並帶 order_id;escalate → 寫佇列,不呼叫 lookup_order。
- 分離 raw 與 visible。tool output 存全量;structured.customer_visible 只含允許展示的欄位。
- 記錄 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。
延伸閱讀
- DevDay 2026 發布了什麼 Decisions、Agents Computer Use 等官方事實
- API 遷移 function_call 與 call_id 欄位
- Agents vs Responses 何時託管 Harness
- JSON Schema 校驗 arguments 與 structured 合約
- 全部文章 更多 JSON 與 AI 開發筆記
更新記錄: 首次發布