Skip to content

feat(a2a)!: upgrade to A2A protocol 1.0 with a2a-java-sdk 1.4.0.Final - #3590

Open
guslegend0510 wants to merge 12 commits into
agentscope-ai:mainfrom
guslegend0510:fix/issue-3546-05-sdk-1-4
Open

guslegend0510 wants to merge 12 commits into
agentscope-ai:mainfrom
guslegend0510:fix/issue-3546-05-sdk-1-4

Conversation

@guslegend0510

@guslegend0510 guslegend0510 commented Oct 15, 2026 •

Copy link
Copy Markdown
Contributor

AgentScope-Java Version

2.1.0-SNAPSHOT (main)

Description

Fixes #3546
Fixes #1336
Fixes #2927
Ref #1209 #1388

把 A2A 客户端、服务端、Spring Boot Starter 和 Nacos 注册从 a2a-java-sdk 0.3.3.Final(A2A 0.3)迁移到 1.4.0.Final(A2A 1.0)。SDK 的包名、Maven 坐标、JSON-RPC 方法名、AgentCard 结构和执行器接口都变了,server 模块又直接复用 client 的消息转换,所以一次性迁移。本 PR 也覆盖了尚未合并的 #2311、#2940、#3289 要解决的问题。按 #3578 下的讨论,#3578 不放进本 PR,升级后基于 1.0 重做。

提交(基于最新 main):

  • 46561dc1d protobuf 升到 4.35.0(SDK 1.4 要求 ≥ 4.33)
  • 7dc5c585b 迁移到 SDK 1.4 / A2A 1.0
  • ce14ec4e0 拆分元数据工具、SDK 反射和 Nacos 安全方案转换(除超时设置外不改行为)
  • 780cb4a96 暂不开放 ListTasks、不再接收推送配置、参数错误保留请求 id、Nacos 接口去重
  • d08ee43b3 请求处理器和 server 可关闭、server 可传入事件总线

主要改动

  • 依赖:三个 SDK 版本属性合并为 a2a-java-sdk.version,groupId 改为 org.a2aproject.sdk。
  • 客户端:适配 1.0 类型;远端任务失败时,错误信息带上远端消息原文;工具结果经 A2A 往返后能还原成 ToolResultBlock([Bug]:ClassCastException in DataPartParser when deserializing ToolResultBlock in Java-to-Java A2A communication #1336)。
  • 服务端:
    • 执行器改用 AgentEmitter,执行和取消逻辑不变;
    • AgentScopeA2aRequestHandler 改为委托 SDK 的 DefaultRequestHandler(1.4 的构造器是包级私有);它和 AgentScopeA2aServer 实现 AutoCloseable,用来停止 SDK 1.4 新增的常驻事件处理线程,Starter 随应用上下文关闭;
    • 两层 builder 新增 mainEventBus(...),自定义 QueueManager 必须一起传入;
    • JSON-RPC 按 1.0 解析和输出,并把 A2A-Version 头传给 SDK 校验;
    • AgentCard 改用 supportedInterfaces(首选接口在前)、securityRequirements 等 1.0 字段;
    • 元数据和 DataPart 数据先转成普通 JSON 值,否则 SDK 会把 ChatUsage 这类对象写成 null。
  • Starter:配置项不变;OAuth 支持 device-code 和 pkce-required;1.0 已删除的 implicit、password 流程,配置了会启动失败,不再被静默丢弃。
  • Nacos:在 1.0 卡片和 Nacos 的 0.3 结构之间显式转换;旧版本注册的卡片能读取,但还调不通 0.3 服务端。
  • 文档:中英文 a2a.md 同步更新。

兼容性(breaking)

  • 只支持 A2A 1.0:0.3 客户端(不带 A2A-Version 头)收到版本错误 -32009,客户端也调不了 0.3 的 Agent。
  • 请求带了 configuration 但没写是否阻塞时,现在按 1.0 默认阻塞(0.3 上为非阻塞)。
  • SDK 包名 io.a2a → org.a2aproject.sdk,公开签名中的 SDK 类型随之变化;AgentScopeA2aRequestHandler 不再继承 DefaultRequestHandler;buildTypeMetadata 移到 MetadataUtil。
  • 自定义 QueueManager 需要同时用 mainEventBus(...) 传入它的事件总线,否则构建失败。
  • ListTasks 返回 UnsupportedOperationError:没有调用方认证时开放它,任何人都能列出所有会话的任务。
  • 不再接收推送配置(卡片本来就声明不支持推送);自定义 store 里已有的配置仍会发送。
  • 元数据里的数字一律是 double:整数到对端会变成 3.0 这样的值,超过 2^53 的整数和 Instant 会损失精度(协议限制)。

后续计划(Follow-up to #3546)

测试

Checklist

  • Code has been formatted with mvn spotless:apply
  • All tests are passing (mvn -B -T1 clean verify)
  • Javadoc comments are complete and follow project conventions
  • Related documentation has been updated (e.g. links, examples, etc.)
  • Code is ready for review

The A2A Java SDK 1.x ships protobuf classes generated for protobuf-java
4.33.1 or later, which refuse to load on the 4.29.3 runtime. Upgrade the
BOM's protobuf-java and the control plane's protoc together so generated
and runtime versions stay in step; gRPC is unchanged.
Migrate the A2A client, server, Spring Boot starter and Nacos registry
from a2a-java-sdk 0.3.3.Final (A2A 0.3) to 1.4.0.Final (A2A 1.0).

- Client: use the 1.0 types; failure messages of remote tasks keep
  their text; tool results survive the round trip (agentscope-ai#1336).
- Server: the executor writes through AgentEmitter; the request handler
  delegates to the SDK DefaultRequestHandler and owns the event bus
  processor; the JSON-RPC wrapper reads and writes A2A 1.0 JSON and
  passes the A2A-Version header on; the agent card lists the supported
  interfaces with the preferred one first.
- Convert metadata and DataPart data to plain JSON values, which the SDK
  would otherwise write as null.
- Starter: support the OAuth device code flow and PKCE; the implicit and
  password flows, removed in A2A 1.0, fail the startup.
- Nacos: convert explicitly between the A2A 1.0 card and the Nacos card,
  which keeps the A2A 0.3 shape.

BREAKING CHANGE: only A2A 1.0 is supported. Requests of A2A 0.3 clients,
which send no A2A-Version header, get a version error, and A2A 0.3
agents cannot be called. The SDK types moved from io.a2a to
org.a2aproject.sdk.

Fixes agentscope-ai#3546
Fixes agentscope-ai#1336
Fixes agentscope-ai#2927
…curity schemes

- Move the part metadata helpers, buildTypeMetadata and the JSON value
  conversion from the client MessageConvertUtil to a new MetadataUtil in
  the message package. The block parsers no longer depend on
  MessageConvertUtil, which depends on them, and the server no longer
  imports helpers from the client converter. Reading a metadata value
  of a part, written four times on both sides, is done once.
- The executor gets the artifact metadata from the server
  MessageConvertUtil instead of converting it itself.
- Keep the reflection on SDK members that are not public in
  SdkInternals, the one place to check when upgrading the SDK. Setting
  the timeouts now fails the build of the request handler when the SDK
  has no such fields, instead of silently keeping the SDK defaults.
- Move the conversion of security schemes from and to the Nacos maps
  out of AgentCardConverterUtil into SecuritySchemeConverterUtil.
- ListTasks is answered with UnsupportedOperationError, by the JSON-RPC
  wrapper and by AgentScopeA2aRequestHandler#onListTasks. AgentScope
  does not authenticate callers yet, so any caller could list the tasks
  and history of every session.
- The request handler disables push notifications, as the agent card
  declares none; the SDK otherwise keeps push configs sent along with a
  message.
- For params the SDK cannot read, it reports some errors without the
  request id; answer them as invalid params of the same request.
- Nacos lists the overwritten preferred interface once when the card
  already has it.
…ough

- SDK 1.4 starts an event processor thread when the request handler is
  built, and nothing stopped it. AgentScopeA2aRequestHandler and
  AgentScopeA2aServer are now AutoCloseable, the Spring Boot starter
  closes the server with its context, and a build that fails after the
  handler was built closes it.
- AgentScopeA2aServer.Builder gets mainEventBus(...), passed to the
  request handler. A custom queue manager without it is rejected: its
  events would go to a bus that nothing consumes.
- Nacos removes every copy of the overwritten interface.
- Document that configs a custom push config store already holds are
  still sent.
@chcodex

chcodex commented Oct 16, 2026

Copy link
Copy Markdown
Contributor

期待合并

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

4 participants