A2A Agent Card Proto 字段编号:v0.3.0 与 v1.0.1

A2A Agent Card Proto 字段编号:v0.3.0 与 v1.0.1

在 protobuf 中,线路上用来标识字段的是字段编号,而不是名称。这对 gRPC 绑定和任何由 a2a.proto 生成的代码都很重要。JSON-RPC 与 HTTP+JSON 绑定使用 camelCase 名称,所以对它们来说,下面的重命名有影响,编号则没有。

官方迁移指南按名称列出字段变化。本页补上编号,数据取自两个 a2a.proto 文件本身(v0.3.0 标签与 v1.0.1 标签)。本页涉及的所有消息,v1.0.0 标签的定义与 v1.0.1 相同。

扩展 Agent Card 标志去哪了?

  • v0.3.0:AgentCard.supports_authenticated_extended_card,bool,13 号字段。
  • v1.0.0 与 v1.0.1:AgentCapabilities.extended_agent_card,optional bool,4 号字段。

规范的迁移附录(A.2.2)描述了同一次迁移,但细节与 proto 文件不一致:

移除新增
v1.0.1 规范的附录 A.2.2AgentCard.supports_extended_agent_card(13 号字段)AgentCapabilities.extended_agent_card(5 号字段)
v0.3.0 与 v1.0.1 的 a2a.protoAgentCard.supports_authenticated_extended_card(13 号字段)AgentCapabilities.extended_agent_card(4 号字段)

附录的旧字段编号是对的,但给旧字段起的名字与 v0.3.0 实际使用的不同,新字段编号写成了 5,而 proto 是 4。AgentCapabilities 的字段是 1 至 4 号,没有 5 号字段。规范明确 a2a.proto 是"唯一权威的规范性定义"(第 1.4 节),请以 proto 为准:4。

AgentCard

编号v0.3.0v1.0.1变化
1namename
2descriptiondescription
3url(string)supported_interfaces(repeated AgentInterface)编号被复用于不同的字段和类型
4providerprovider
5versionversion
6documentation_urldocumentation_url现为 optional
7capabilitiescapabilities
8security_schemessecurity_schemes
9security(repeated Security)security_requirements(repeated SecurityRequirement)重命名;结构相同
10default_input_modesdefault_input_modes
11default_output_modesdefault_output_modes
12skillsskills
13supports_authenticated_extended_card(bool)signatures(repeated AgentCardSignature)编号被复用于不同的字段和类型
14preferred_transport(string)icon_url(optional string)编号被复用;两者都是字符串
15additional_interfaces未使用并入 supported_interfaces
16protocol_version未使用移到 AgentInterface.protocol_version
17signatures未使用移到 13 号字段

AgentCapabilities

编号v0.3.0v1.0.1变化
1streaming(bool)streaming(optional bool)现为 optional
2push_notifications(bool)push_notifications(optional bool)现为 optional
3extensionsextensions
4无extended_agent_card(optional bool)新增;见上文

AgentInterface

编号v0.3.0v1.0.1变化
1urlurl
2transportprotocol_binding重命名
3无tenant新增
4无protocol_version新增;取代 AgentCard.protocol_version(16 号字段)

AgentSkill

1 至 7 号字段完全相同。8 号字段从 security(repeated Security)变为 security_requirements(repeated SecurityRequirement);见 AgentSkill 。

未变化的消息

下列消息在 v0.3.0 与 v1.0.1 中的字段名称、编号和类型完全一致:AgentProvider、AgentExtension 和 AgentCardSignature。

可以得出的结论

  • 三个编号的含义变了。 3 号字段从字符串变成消息列表,13 号字段从 bool 变成消息列表,14 号字段从一个字符串变成另一个字符串。用一个定义写出的字节,按另一个定义生成的代码去读,可能读错值或解析失败。接口会声明 protocol_version,请求还带有 A2A-Version 服务参数,服务器因此能分辨客户端使用的是哪个定义。
  • 没有保留任何编号。 v1.0.1 的 proto 中没有 reserved 语句。AgentCard 的 15、16、17 号只是闲置,消息里写着注释 Next ID: 20;文件中没有任何内容阻止后续修改复用它们。
  • optional 的作用不止风格。 规范第 5.7 节给出了使用该关键字的两个理由:默认值与 protobuf 隐式默认值不同的字段,以及 Agent Card 签名,optional 用来区分显式设置的字段(属于规范化形式)与被省略的字段。在 v1.0.1 中,streaming、push_notifications、extended_agent_card、documentation_url 和 icon_url 都是 optional。见 Agent Card 签名 。

自行核对

git clone https://github.com/a2aproject/A2A && cd A2A
git show v0.3.0:specification/grpc/a2a.proto | sed -n '/^message AgentCard {/,/^}/p'
git show v1.0.1:specification/a2a.proto      | sed -n '/^message AgentCard {/,/^}/p'
git show v1.0.1:specification/a2a.proto      | sed -n '/^message AgentCapabilities {/,/^}/p'

v0.3.0 的 proto 位于 specification/grpc/ 下;从 v1.0 起为 specification/a2a.proto。

相关页面

来源:a2a.proto 的 v0.3.0 、v1.0.0 与 v1.0.1 版本;A2A 官方规范:Normative Content、Field Presence and Optionality、Appendix A.2