Skip to content

docs: clarify chat output mode contract#381

Merged
liujuanjuan1984 merged 1 commit intomainfrom
chore/379-output-modes-review
Apr 2, 2026
Merged

docs: clarify chat output mode contract#381
liujuanjuan1984 merged 1 commit intomainfrom
chore/379-output-modes-review

Conversation

@liujuanjuan1984
Copy link
Copy Markdown
Collaborator

背景

本 PR 聚焦 #379,把现有的 chat acceptedOutputModes fail-fast 校验提升为更明确的公开契约表达。

当前主逻辑已经会在入口和 executor 层拒绝不接受 text/plain 的 chat 请求,但文档与 Agent Card skill 描述此前还没有把这层边界直接说透,客户端容易把 default_output_modes = [text/plain, application/json] 误解成“只接受 application/json 也总能工作”。

Guide 契约说明

  • docs/guide.md 的 Core Behavior 段落补充 chat output modes consumer guidance。
  • 明确说明:
    • 显式 configuration.acceptedOutputModes 必须与 chat 声明能力兼容。
    • 当前 main chat 请求必须继续接受 text/plain
    • application/json 是增量结构化输出支持,不承诺普通 assistant prose 都能无损表示为 JSON。

Agent Card 技能说明

  • src/opencode_a2a/server/agent_card.pyopencode.chat skill description 中补充同样的边界说明。
  • 保持现有 skill/output modes 声明不变,不额外引入新的 extension 字段或 metadata 面。

Tests

  • tests/server/test_app_behaviors.py 补充更聚焦的入口契约测试:
    • acceptedOutputModes=["application/json"] 时在入口拒绝,并稳定断言错误 data 字段。
    • acceptedOutputModes=["image/png"] 时在入口拒绝,并稳定断言错误 data 字段。
  • tests/server/test_agent_card.py 增加 chat skill 文案断言,防止 Agent Card 说明回退。

验证

  • uv run pytest --no-cov tests/server/test_app_behaviors.py tests/server/test_agent_card.py -q
  • ./scripts/doctor.sh

Issue 关联

Closes #379

@liujuanjuan1984
Copy link
Copy Markdown
Collaborator Author

聚焦本 PR 代码变动的自审结论:未发现阻塞性问题。

审查结论:

  • 改动范围与 #379 的目标一致,保持在“公开契约固化”边界内,没有额外扩张到新的运行时主逻辑。
  • docs/guide.md 补充的 consumer guidance 与当前已有实现一致:chat 请求显式声明 acceptedOutputModes 时必须兼容已声明能力,且当前 main chat 仍要求接受 text/plain
  • src/opencode_a2a/server/agent_card.py 只补充了 opencode.chat skill 的边界说明,没有引入新的 metadata 面或 discoverability 变化,风险较低。
  • tests/server/test_app_behaviors.py 对入口拒绝场景补了更聚焦的断言,覆盖了“仅接受 application/json”和“完全不兼容 mode”两类失败路径,并稳定断言了错误 data 字段,能更好地锁定契约回归。
  • tests/server/test_agent_card.py 对 chat skill 文案补了最小断言,能防止 Agent Card 说明回退,同时不会把整段文案做成脆弱快照。

风险判断:

  • 未发现行为回归风险。
  • 文档与 skill 描述新增的是解释性约束,不改变现有 runtime 路径;对应测试也已覆盖入口 fail-fast 的稳定契约。

Issue 关系审查:

  • PR 描述中的 Closes #379 是准确的。
  • 当前不需要补充其它 Related / Closes 关系;本 PR 没有引入需要同步关闭的其它 issue。

验证:

  • uv run pytest --no-cov tests/server/test_app_behaviors.py tests/server/test_agent_card.py -q
  • ./scripts/doctor.sh

结果:482 passed,总覆盖率 91.42%

@liujuanjuan1984 liujuanjuan1984 merged commit b4c0bc7 into main Apr 2, 2026
3 checks passed
@liujuanjuan1984 liujuanjuan1984 deleted the chore/379-output-modes-review branch April 2, 2026 12:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Priority: Med] [Contracts] 明确 chat acceptedOutputModes 前置校验与输出模式边界

1 participant