fix: chain reactive hooks using flatMap to preserve event modifications in A2aAgent#1126
Closed
jujn wants to merge 3 commits intoagentscope-ai:mainfrom
Closed
fix: chain reactive hooks using flatMap to preserve event modifications in A2aAgent#1126jujn wants to merge 3 commits intoagentscope-ai:mainfrom
jujn wants to merge 3 commits intoagentscope-ai:mainfrom
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR fixes A2aAgent streaming hook behavior so that hook-returned (potentially modified) HookEvents are passed to subsequent hooks, aligning A2A streaming with the intended “hook chain” semantics and resolving cases like TTSHook-style plugin pipelines.
Changes:
- Update
TaskUpdateEventHandlerto chain hook execution usingMono.flatMap(...)so event modifications propagate through the hook sequence. - Add a regression test ensuring a modified
ReasoningChunkEventproduced by an earlier hook is observed by later hooks during streaming.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| agentscope-extensions/agentscope-extensions-a2a/agentscope-extensions-a2a-client/src/main/java/io/agentscope/core/a2a/agent/event/TaskUpdateEventHandler.java | Chains hook execution via flatMap to preserve event modifications across hooks for streaming chunk updates. |
| agentscope-extensions/agentscope-extensions-a2a/agentscope-extensions-a2a-client/src/test/java/io/agentscope/core/a2a/agent/A2aAgentTest.java | Adds a streaming regression test verifying hook-chain event modification propagation (and side-effect execution). |
...gentscope-extensions-a2a-client/src/test/java/io/agentscope/core/a2a/agent/A2aAgentTest.java
Outdated
Show resolved
Hide resolved
...gentscope-extensions-a2a-client/src/test/java/io/agentscope/core/a2a/agent/A2aAgentTest.java
Outdated
Show resolved
Hide resolved
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
|
你好,感谢pr, 我拉取了你的分支本地构建,在使用springboot流式接口时,还是没有生效,现在是这样的(目前1.0.11也是): |
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.


Description
Close #1120
This PR fixes the issue where plugins like TTSHook failed in A2aAgent by chaining the hook executions with flatMap instead of isolated blocks.
Checklist
Please check the following items before code is ready to be reviewed.
mvn spotless:applymvn test)