Claude Opus 5.5 與 GPT-6 Astra 對比:Coding Agent 的 JSON、Tool Calling 與 Structured Output 怎麼接?
兩家旗艦都面向長任務 Coding Agent,但JSON 合約不在同一套 API 裡。Opus 5.5 走 Anthropic Messages:tools[].input_schema、回覆裡的 tool_use / 寫回的 tool_result、結構化物件在 output_config.format。GPT-6 Astra 走 OpenAI Responses:text.format、扁平 tools[]、輸出項 function_call、續聊 previous_response_id。本文只做欄位對照與宿主檢查清單,不做模型排名。
閱讀前速覽
| 維度 | Claude Opus 5.5 | GPT-6 Astra |
|---|---|---|
| API 面 | POST /v1/messages;messages[] 續聊 | POST /v1/responses;previous_response_id 續聊 |
| Structured Output | output_config.format type=json_schema strict | text.format type=json_schema strict |
| Tool Calling | tools[].input_schema;tool_use / tool_result | 扁平 tools[];function_call / function_call_output |
| tool_choice | forced 指定工具會報錯;靠 Schema 收窄 | Responses 上 auto / none;DevDay 後工具走此面 |
| Session | 宿主拼 messages 歷史(可疊 session_id 狀態) | previous_response_id 鏈;Decisions 路由另算 |
事實截至 2026-11-02:Anthropic Opus 5.5 文件、OpenAI Astra / Responses 遷移與 Structured Outputs 文件。A-1042、resp_8k1a 為虛構。
差的是 API 形狀,不是「同一種 JSON mode」
Coding Agent 宿主通常要同時處理三件事:給 UI 的結構物件、模型發起的工具參數、以及寫回後的下一跳。Opus 5.5 與 Astra 都能做,但欄位名與續聊方式不同:
- Opus 5.5 在 Messages 裡宣告
input_schema;模型返回tool_use(input已是物件)。結構化抽取用output_config.format,不是把 schema 塞進 user 文字。 - GPT-6 Astra 帶工具時應走 Responses:扁平
type/name/parameters,arguments常為字串;寫回用function_call_output對齊call_id。物件生成用text.format。 - 宿主職責不變:Schema 校驗、權限、執行副作用、持久化 state。換模型不等於刪掉 JSON 門;只是 parser 與 id 欄位要換一套。
單邊深讀見 Opus 5.5 深讀 與 GPT-6 Astra 深讀;OpenAI 側 DevDay 後分路見 DevDay Structured Output;通用 Coding Agent 循環見 Coding Agent 循環。
Opus 工具 / 結構化 vs Astra text.format / 扁平工具
1. Opus 5.5:Messages + input_schema 工具表。 與 Coding Agent 裡「查單再回答」同一虛構訂單 A-1042:
{
"model": "claude-opus-5-5",
"max_tokens": 16000,
"effort": "medium",
"tools": [{
"name": "lookup_order",
"description": "Look up an order by ID. Confirm before any refund.",
"input_schema": {
"type": "object",
"properties": {
"order_id": { "type": "string", "pattern": "^[A-Z]-\\d{4}$" }
},
"required": ["order_id"],
"additionalProperties": false
}
}],
"messages": [{
"role": "user",
"content": "Look up order A-1042 and say if it is paid."
}]
}
2. Opus 5.5:只要 UI 物件時開 output_config.format。 與工具呼叫分請求;不要在同一次裡既 forced 工具又塞 giant schema 路由。
{
"model": "claude-opus-5-5",
"max_tokens": 8192,
"effort": "medium",
"messages": [{
"role": "user",
"content": "Extract order A-1042 as JSON for the UI."
}],
"output_config": {
"format": {
"type": "json_schema",
"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. Astra:Responses + text.format 抽欄位。 官方 Structured Outputs 掛點在 text.format,不是 Chat Completions 的 response_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
}
}
}
}
4. Astra:副作用用扁平 strict tools + previous_response_id。 續聊不要把整段 function_call 歷史手工 stringify;用 response id 連結。
{
"model": "gpt-6-astra",
"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." }]
}]
}
同一條 Coding Agent:該走哪條 API?
按「返回合約」選,不要按「誰更聰明」選。下面假設宿主已有一層 vendor 抽象:
| 你需要 | Opus 5.5 | GPT-6 Astra |
|---|---|---|
| 給 UI / 下游的結構物件 | Messages output_config.format json_schema | Responses text.format json_schema |
| 查庫、改檔案、跑命令 | tools + tool_use;tool_result 寫回 | Responses flat tools + function_call_output |
| 長任務多輪(數十 turn) | messages[] + 宿主 JSON state | previous_response_id 鏈 + 宿主 state |
| 強制「必須呼叫 lookup_order」 | 避免 forced tool_choice;用 Schema 與 prompt | tool_choice auto/none;不要假設 forced 穩定 |
| OpenAI 有界路由(部門/是否升級) | 宿主規則或 Decisions(若已接 OpenAI 棧) | Decisions answers;見 DevDay 分路文 |
Programmatic Tool Calling、Agents API 託管循環是 OpenAI 側能力;Opus 宿主仍用 Messages 形狀。抽象層應儲存「原始 output 項 + 規範化後的業務 JSON」,而不是隻存一種 vendor 字串。
雙棧 Coding Agent 接入五步
在 staging 用同一虛構工單跑 Opus 與 Astra 各一遍,再並生產:
- 拆三份合約。 UI 物件 schema、每個工具的 parameters/input_schema、寫回結果 schema。
- 為 Opus 寫 Messages 介面卡。解析 tool_use.id → 執行 → tool_result.tool_use_id。
- 為 Astra 寫 Responses 介面卡。解析 function_call.call_id → function_call_output。
- 結構化路徑分開。Opus 用 output_config.format;Astra 用 text.format;不要混在工具請求裡。
- state 裡存 vendor 無關 facts。order_id、route、pending_tool 進 JSON state;原始 call id 僅用於寫回對齊。
五段循環欄位(Request → Call → Result → State → Next)見 Agent JSON State 文;本篇只保證 Call/Result 形狀隨 vendor 切換。
把 arguments、input、format 結果攤開看
雙棧 Bug 多半是「用 Astra 的 call_id 寫 Opus 的 tool_result」或「把 tool_use.input 當字串再 parse 一次」。
- 用 格式化 展開 tool_use.input、function_call.arguments 與 format 結果;用 Schema 校驗 校驗兩邊 schema。
- 用 JSON Diff 對比同一 turn 的 Opus messages 與 Astra input 項,確認沒有混用 response_format。
- 用 JSONPath 從宿主 state 取 last_order_id,確認與工具參數一致。
- 循環欄位清單見 Agent JSON State。
- JSONSort 本地處理;不要上傳真實倉庫路徑或金鑰。
兩邊 JSON 分別過 Schema,才算接好,而不是「看起來都能 parse」。
常見誤區
- 以為兩家共用 Chat Completions function 包裝。Astra 帶工具應走 Responses 扁平形狀。
- 在 Opus 上 forced tool_choice 當穩定器。官方路徑會報錯;用 Schema 與描述收窄。
- 把 output_config.format 與 tools 擠進一次 Messages 當「全能 schema」。物件與副作用應分請求或分 turn。
- 忽略 arguments 是字串。Astra function_call 需 parse + Schema;Opus tool_use.input 已是物件但仍要校驗。
- 用 previous_response_id 卻改 tools 表不 versioning。宿主應記錄 tools 版本與 response id 一起 replay。
- 寫成「誰更強」選型文。事實是 API 與 id 不同;選型應看合規、latency、已有棧與託管能力。
FAQ
能不能讓 Opus 也走 OpenAI Responses?
不能混 API。抽象層可以在自家服務裡統一「業務 JSON」,但 HTTP 形狀必須按各 vendor 文件發。
Astra 還能用 Chat Completions 嗎?
無工具的請求可以;帶 tool calling 的 Astra 應遷 Responses。見 DevDay 後遷移說明。
Structured Output 能代替 Tool Calling 嗎?
不能。format/json_schema 約束的是模型文字輸出;副作用仍要工具通道,宿主執行。
MCP 與 function calling 怎麼和本篇關係?
MCP 是宿主連外部工具的協議;模型側仍是 tool_use 或 function_call。MCP 不替換 Schema 門。
同一 Agent 能否預設 Opus、fallback Astra?
可以,但要有兩套 parser、兩套 id 寫回與獨立的 replay 日誌。不要假設 output 項結構相同。
結論
Claude Opus 5.5 與 GPT-6 Astra 對 Coding Agent 都強調長任務與工具 JSON,但合約落在不同 API:Messages + output_config + tool_use,對比 Responses + text.format + function_call。
先畫三份 schema 與寫回 id 規則,再選模型。模型只填 JSON;執行、權限與下一跳永遠是宿主的事。
延伸閱讀
- Claude Opus 5.5 與工具 JSON Messages、effort、tool_use 寫回
- GPT-6 Astra 與 JSON API Responses、text.format、async 工具
- DevDay 後 Structured Output 變化 text.format、扁平 tools、Decisions 分路
- AI Coding Agent 與 JSON 通用循環、宿主執行
- 全部文章 更多 JSON 與 AI 開發筆記
更新記錄: 首次發布