fix(A2A): fix A2aAgent lifecycle events to support TTSHook and reasoning completion#1150
Open
jujn wants to merge 2 commits intoagentscope-ai:mainfrom
Open
fix(A2A): fix A2aAgent lifecycle events to support TTSHook and reasoning completion#1150jujn wants to merge 2 commits intoagentscope-ai:mainfrom
jujn wants to merge 2 commits intoagentscope-ai:mainfrom
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR fixes A2aAgent lifecycle hook behavior so that reasoning lifecycle events (PreReasoning / ReasoningChunk / PostReasoning) are emitted in a consistent order, enabling plugins like TTSHook to work correctly with A2A streaming.
Changes:
- Introduces unified lifecycle event publishing in
ClientEventContext(pre/chunk/post). - Updates A2A client event handlers to use the unified publishing APIs and trigger PreReasoning/PostReasoning at the right times.
- Extends
A2aAgentTestto validate lifecycle hook triggering and updates stream expectations to include PostReasoning.
Reviewed changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| agentscope-extensions/agentscope-extensions-a2a/agentscope-extensions-a2a-client/src/main/java/io/agentscope/core/a2a/agent/A2aAgent.java | Captures input messages into the client event context for PreReasoning emission. |
| agentscope-extensions/agentscope-extensions-a2a/agentscope-extensions-a2a-client/src/main/java/io/agentscope/core/a2a/agent/event/ClientEventContext.java | Adds unified APIs to publish Pre/Chunk/Post reasoning hook events with “fire once” guards. |
| agentscope-extensions/agentscope-extensions-a2a/agentscope-extensions-a2a-client/src/main/java/io/agentscope/core/a2a/agent/event/TaskEventHandler.java | Triggers PreReasoning when a task is created. |
| agentscope-extensions/agentscope-extensions-a2a/agentscope-extensions-a2a-client/src/main/java/io/agentscope/core/a2a/agent/event/TaskUpdateEventHandler.java | Routes task updates through unified chunk/post publishers (instead of ad-hoc hook calls). |
| agentscope-extensions/agentscope-extensions-a2a/agentscope-extensions-a2a-client/src/main/java/io/agentscope/core/a2a/agent/event/MessageEventHandler.java | Triggers post reasoning lifecycle on single-message completion flows. |
| agentscope-extensions/agentscope-extensions-a2a/agentscope-extensions-a2a-client/src/test/java/io/agentscope/core/a2a/agent/A2aAgentTest.java | Updates stream assertions and adds a new test for lifecycle hook triggering. |
...tensions-a2a-client/src/main/java/io/agentscope/core/a2a/agent/event/ClientEventContext.java
Show resolved
Hide resolved
...tensions-a2a-client/src/main/java/io/agentscope/core/a2a/agent/event/ClientEventContext.java
Outdated
Show resolved
Hide resolved
...ions-a2a-client/src/main/java/io/agentscope/core/a2a/agent/event/TaskUpdateEventHandler.java
Outdated
Show resolved
Hide resolved
...ensions-a2a-client/src/main/java/io/agentscope/core/a2a/agent/event/MessageEventHandler.java
Show resolved
Hide resolved
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
|
测试了,可以了,谢谢 |
Contributor
Author
感谢反馈 |
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 introducing a state machine in ClientEventContext to guarantee the execution order of PreReasoningEvent, ReasoningChunkEvent, and PostReasoningEvent.
Checklist
Please check the following items before code is ready to be reviewed.
mvn spotless:applymvn test)