Repository navigation
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
Open
guslegend0510 wants to merge 12 commits into
guslegend0510 wants to merge 12 commits into
Conversation
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.
Contributor
|
期待合并 |
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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):
46561dc1dprotobuf 升到 4.35.0(SDK 1.4 要求 ≥ 4.33)7dc5c585b迁移到 SDK 1.4 / A2A 1.0ce14ec4e0拆分元数据工具、SDK 反射和 Nacos 安全方案转换(除超时设置外不改行为)780cb4a96暂不开放 ListTasks、不再接收推送配置、参数错误保留请求 id、Nacos 接口去重d08ee43b3请求处理器和 server 可关闭、server 可传入事件总线主要改动
a2a-java-sdk.version,groupId 改为org.a2aproject.sdk。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 随应用上下文关闭;mainEventBus(...),自定义QueueManager必须一起传入;A2A-Version头传给 SDK 校验;supportedInterfaces(首选接口在前)、securityRequirements等 1.0 字段;DataPart数据先转成普通 JSON 值,否则 SDK 会把ChatUsage这类对象写成null。device-code和pkce-required;1.0 已删除的implicit、password流程,配置了会启动失败,不再被静默丢弃。兼容性(breaking)
A2A-Version头)收到版本错误 -32009,客户端也调不了 0.3 的 Agent。configuration但没写是否阻塞时,现在按 1.0 默认阻塞(0.3 上为非阻塞)。io.a2a→org.a2aproject.sdk,公开签名中的 SDK 类型随之变化;AgentScopeA2aRequestHandler不再继承DefaultRequestHandler;buildTypeMetadata移到MetadataUtil。QueueManager需要同时用mainEventBus(...)传入它的事件总线,否则构建失败。ListTasks返回UnsupportedOperationError:没有调用方认证时开放它,任何人都能列出所有会话的任务。3.0这样的值,超过 2^53 的整数和Instant会损失精度(协议限制)。后续计划(Follow-up to #3546)
A2A-Version主版本分流,0.3 客户端交给 SDK 的 0.3 兼容层。INPUT_REQUIRED续接(客户端)。ListTasks。测试
A2aHttpEndToEndTest(真实 HTTP):启用工具结果用例([Bug]:ClassCastException in DataPartParser when deserializing ToolResultBlock in Java-to-Java A2A communication #1336);远端失败断言带上原文;新增「流式结束后不误报错误」([Bug]:JSON-RPC streaming client reports "Request cancelled" after receiving final TaskStatusUpdateEvent #2927,只在 1.4 上验证)和「不带版本头被拒」。interruptCancelsRemoteTask在 1.4 上仍失败(与 0.3 相同),保持@Disabled,由 fix(a2a): 取消任务后结束服务端执行,并释放服务端线程池 #3578 修复。mvn -B -T1 clean verify97 个模块全部通过(10,823 个测试,0 失败,200 跳过);补丁覆盖率:行 547/594,分支 194/238。Checklist
mvn spotless:applymvn -B -T1 clean verify)