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 开发笔记
更新记录: 首次发布