Skip to content

feat: add A2A dual-stack compatibility foundations#382

Merged
liujuanjuan1984 merged 3 commits intomainfrom
chore/368-a2a-version-negotiation-review
Apr 2, 2026
Merged

feat: add A2A dual-stack compatibility foundations#382
liujuanjuan1984 merged 3 commits intomainfrom
chore/368-a2a-version-negotiation-review

Conversation

@liujuanjuan1984
Copy link
Copy Markdown
Collaborator

背景

本 PR 基于同一条协议兼容主线,补齐当前 opencode-a2a 对 A2A 0.3 / 1.0 双轨兼容的基础设施、错误封装与公开支持边界。

协议协商基础设施

  • 规范化协议版本配置为 Major.Minor 语义,并引入 default_protocol_version / supported_protocol_versions
  • 在服务端统一解析 A2A-Version header 与 query 参数,对不支持版本在路由前集中拒绝
  • 在客户端统一注入 outbound A2A-Version,避免调用侧继续散落协议版本判断
  • 将协商结果同步到 Agent Card / OpenAPI 的 compatibility metadata

错误封装与协议适配

  • jsonrpc/error_responses.py 增加集中式协议感知错误整形
  • 保持 0.3 现有 legacy JSON-RPC / REST 错误契约不变
  • 1.0 / 1.x 增加:
    • standard JSON-RPC errors 的标准 message 与 camelCase data
    • A2A-specific JSON-RPC errors 的 google.rpc.ErrorInfo 风格 details
    • REST transport / protocol errors 的 AIP-193 风格 error.details[]
  • 通过 request-scoped context 把协议版本传递到 JSON-RPC extension handler,避免把版本分支散落到各个 handler

兼容矩阵与公开支持边界

  • 在 compatibility profile / wire contract 中新增 machine-readable protocol_compatibility 摘要
  • README.mddocs/guide.mddocs/extension-specifications.md 补齐 0.3 / 1.0 compatibility matrix
  • 明确当前支持边界:
    • 0.3 = supported
    • 1.0 = partial
  • 明确公开当前已知缺口:
    • AgentInterface.protocolVersion 仍受 a2a-sdk==0.3.25 限制
    • transport payloads / enums / pagination / signatures / push-notification surfaces 仍沿用 SDK-owned 0.3 baseline

测试与验证

  • 补齐 client / config / transport / Agent Card / contract consistency / JSON-RPC error shaping 相关测试
  • 已运行 ./scripts/doctor.sh
  • 结果:495 passed,总覆盖率 91.36%

Issue 关联

@liujuanjuan1984
Copy link
Copy Markdown
Collaborator Author

本轮聚焦 PR 代码变动自审,结论如下。

  1. 未发现阻塞性问题。
  2. #368 的版本协商基础设施实现是合理的:协议归一化、inbound negotiation、outbound header 注入都集中在 protocol_versions.py、middleware、request context 这一层,没有把版本判断散落到业务 handler。
  3. #369 的错误封装实现是稳健的:0.3 继续保持 legacy 行为,1.x 只在协商后的协议路径切换错误形状;JSON-RPC 与 REST 都通过集中式 helper 整形,避免逐 handler 手写 payload。
  4. #348 的兼容矩阵实现是恰当的:protocol_compatibility 作为 SSOT 同步到 compatibility profile 与 wire contract,并用 Agent Card / OpenAPI / contract consistency 测试锁定一致性,做法简洁且不冗余。

当前仍有两个已知边界,但它们不是本 PR 的遗漏,而是已被显式公开的兼容范围:

  • a2a-sdk==0.3.25 仍不支持 AgentInterface.protocolVersion,因此 interface-level 标准声明还不能完整做到。
  • 1.0 当前是 partial 支持,transport payloads / enums / pagination / signatures / push-notification 仍沿用 SDK-owned 0.3 baseline。

PR 与 issue 的关系我也复核过:

  • Closes #368Closes #369Closes #348 准确。
  • Related #367 作为 umbrella issue 关联也准确,不应关闭。

@liujuanjuan1984 liujuanjuan1984 merged commit 8dc313a into main Apr 2, 2026
3 checks passed
@liujuanjuan1984 liujuanjuan1984 deleted the chore/368-a2a-version-negotiation-review branch April 2, 2026 14:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

1 participant