fix(agui): fix AG-UI reasoning/tool event handling#1231
Merged
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
Fixes AG-UI adapter event conversion to better match the AG-UI reasoning/tool-call protocol expectations (closing #1230), improving frontend compatibility for reasoning display and tool-call sequencing.
Changes:
- Emit
ReasoningMessageStartwith role"reasoning"(instead of"assistant"). - Explicitly close an active reasoning message before emitting
ToolCallStartwhen aToolUseBlockarrives. - When backfilling
ToolCallStartfrom aToolResultBlock, use the tool’s real name when present (fallback to"unknown"only when missing).
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| agentscope-extensions/agentscope-extensions-agui/src/main/java/io/agentscope/core/agui/adapter/AguiAgentAdapter.java | Updates AG-UI event conversion logic for reasoning role, reasoning/tool ordering, and tool-name backfill. |
| agentscope-extensions/agentscope-extensions-agui/src/test/java/io/agentscope/core/agui/adapter/AguiAgentAdapterTest.java | Updates/adds assertions to validate the corrected reasoning role, sequencing (reasoning end before tool start), and tool-name backfill. |
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
liangxingguang
pushed a commit
to liangxingguang/agentscope-java
that referenced
this pull request
May 21, 2026
## Description Close agentscope-ai#1230 This PR fixes three AG-UI adapter issues: (1) ReasoningMessageStart now uses role reasoning (instead of assistant) to match protocol expectations(current issue). (2) Active reasoning messages are explicitly closed before emitting ToolCallStart when a ToolUseBlock arrives. (3) Backfilled ToolCallStart now uses the real tool name from ToolResultBlock (falling back to unknown only when missing). ## Checklist Please check the following items before code is ready to be reviewed. - [ ] Code has been formatted with `mvn spotless:apply` - [ ] All tests are passing (`mvn test`) - [ ] Javadoc comments are complete and follow project conventions - [ ] Related documentation has been updated (e.g. links, examples, etc.) - [ ] Code is ready for review
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 #1230
This PR fixes three AG-UI adapter issues:
(1) ReasoningMessageStart now uses role reasoning (instead of assistant) to match protocol expectations(current issue).
(2) Active reasoning messages are explicitly closed before emitting ToolCallStart when a ToolUseBlock arrives.
(3) Backfilled ToolCallStart now uses the real tool name from ToolResultBlock (falling back to unknown only when missing).
Checklist
Please check the following items before code is ready to be reviewed.
mvn spotless:applymvn test)