Repository navigation
fix(a2a): close the client of cancelled calls and stop using a lifecycle hook - #3663
Merged
jujn merged 1 commit intoOct 20, 2026
Merged
Conversation
…cle hook A2aAgent built its A2A client in a PreCall hook and closed it in the PostCall and Error hooks, keeping the client and the event context of the call in fields. A cancelled call fires neither hook, so its client was never closed. The hook API is also deprecated for removal. The client and the event context now belong to the call: they are created when the call starts, and the client is closed however the call ends, cancellation included. Only a reference to the call in progress is kept, for interrupt(). The internal hook no longer shows up in getHooks(); hooks given to the builder work as before. A2aAgent now uses the AgentBase constructor without checkRunning, which had no effect, and Builder.checkRunning is deprecated.
jujn
approved these changes
Oct 20, 2026
This was referenced Oct 20, 2026
5 tasks done
chickenlj
pushed a commit
that referenced
this pull request
Nov 13, 2026
…cle hook (#3663) Backport the verified fix to the 2.0.x implementation and retain its existing public contracts where the upstream kernel differs. (cherry picked from commit 73cb2da) Backport-review-patch: eb66dd61f9d5177f6804aef339bc7c08d995cc4f Constraint: No AgentScope Service or SDK migration Confidence: high Not-tested: Whole-repository verification pending after lane integration
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
A2A client 去掉弃用 API 的第一步:
A2aAgent内部不再用 Hook 管理 A2A client,顺带修掉取消调用时 client 不关闭的问题。不改公开 API(只把一个本来就不起作用的 Builder 方法标为弃用)。问题
A2aAgent用一个内部 Hook 管理 A2A client:PreCall 时创建,PostCall 和 Error 时关闭;client、事件上下文和请求 id 都放在字段上。PreCallEvent/PostCallEvent/ErrorEvent/HookEvent都是@Deprecated(forRemoval = true)。改动
Mono.using保证成功、失败、取消都会关闭 client。字段上只保留「当前调用」的引用,给interrupt()用。getHooks()只返回用户给的 Hook。用户的 Hook(包括 Pre/Chunk/PostReasoning)和弃用的stream()行为不变。checkRunning的AgentBase构造器(这个参数在AgentBase里本来就被忽略),Builder.checkRunning(...)标为@Deprecated。clientReplacer:仍按配置真实构建 client,再换成 mock,原来覆盖的构建逻辑(自定义 transport、transport 不存在时报错)照常覆盖。不在本 PR
streamEvents()、middleware、Memory改用AgentState、按RuntimeContext中断,后续分别提小 PR。测试
getHooks()只有用户给的 Hook。两条在 main 上都会失败。A2aHttpEndToEndTest(真实 HTTP,包括用 Hook 收流式分块的用例)14 个里 13 个通过、1 个跳过(等 fix(a2a): 取消任务后结束服务端执行,并释放服务端线程池 #3578 的中断用例);Nacos A2A 模块全部通过。mvn -B -T1 clean verify97 个模块全部通过(10,938 个测试,0 失败,200 跳过)。补丁覆盖率:行 36/36,分支 1/2(未覆盖的是测试不替换 client 的分支,由 Starter 端到端测试覆盖)。Checklist
mvn spotless:applymvn -B -T1 clean verify)