-
Notifications
You must be signed in to change notification settings - Fork 0
[Priority: Med] [Contracts] 明确 chat acceptedOutputModes 前置校验与输出模式边界 #379
Copy link
Copy link
Closed
Description
背景
- 在对照
codex-a2a与opencode-a2a的 input/output modes 实现时,发现opencode-a2a当前已经做了比较清晰的输入边界约束,但输出 modes 侧仍有一处可进一步收口的契约表达。 codex-a2a最近补上了 task-scoped 的acceptedOutputModes协商持久化;反过来看,opencode-a2a有一条实践值得继续固化并补齐文档:对 chat 请求做 fail-fast 的 output modes 兼容性校验。
现状
- 当前实现已经在入口和 executor 层要求 OpenCode chat 至少接受
text/plain,否则会返回明确错误,而不是在运行过程中隐式丢内容。 - 这条约束本身是合理的,因为 OpenCode chat 的自然语言主输出仍以
TextPart为主;application/json仅覆盖结构化tool_call增量,不足以表达全部正常回复。 - 但这条设计意图在 guide 中还没有被直接说透,客户端读 Agent Card / guide 时,仍可能把
default_output_modes = [text/plain, application/json]误解成“只接受 application/json 也总能工作”。
建议
- 将当前的 fail-fast 校验提升为显式稳定契约:对于 main chat,若请求声明了
acceptedOutputModes,则必须与服务声明能力兼容,且必须包含text/plain。 - 在 guide 中直接补一句 consumer guidance:
application/json是增量结构化输出能力,不承诺所有自然语言回复都能无损升级为 JSON;期望普通 assistant prose 的客户端应继续接受text/plain。 - 为这条约束补一组更聚焦的契约测试,覆盖:
acceptedOutputModes=["application/json"]时在入口被拒绝- 错误类型/消息/数据字段稳定
- Agent Card / guide /测试三处表达一致
可参考的另一方向
- 若未来
opencode-a2a放宽 output modes 协商能力,可以参考codex-a2a刚补上的 task-scoped negotiation persistence:同一 task 的message/send、message/stream、tasks/get、tasks/resubscribe、push notification 应共享同一 negotiated output surface,而不是只在当前响应出口做一次性降级。 - 相关参考实现与讨论见:
价值
- 降低客户端误解 Agent Card modes 的概率
- 让失败更早、更稳定、更容易调试
- 为后续若要扩展更细粒度 output negotiation 留出清晰的契约起点
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels