Thanks to visit codestin.com
Credit goes to github.com

Skip to content

fix(agui): fix AG-UI reasoning/tool event handling#1231

Merged
LearningGp merged 2 commits into
agentscope-ai:mainfrom
jujn:fix_1230
Apr 28, 2026
Merged

fix(agui): fix AG-UI reasoning/tool event handling#1231
LearningGp merged 2 commits into
agentscope-ai:mainfrom
jujn:fix_1230

Conversation

@jujn
Copy link
Copy Markdown
Contributor

@jujn jujn commented Apr 16, 2026

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.

  • 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

@jujn jujn requested review from a team and Copilot April 16, 2026 06:23
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 ReasoningMessageStart with role "reasoning" (instead of "assistant").
  • Explicitly close an active reasoning message before emitting ToolCallStart when a ToolUseBlock arrives.
  • When backfilling ToolCallStart from a ToolResultBlock, 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
Copy link
Copy Markdown

codecov Bot commented Apr 16, 2026

Codecov Report

❌ Patch coverage is 64.70588% with 6 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
...agentscope/core/agui/adapter/AguiAgentAdapter.java 64.70% 1 Missing and 5 partials ⚠️

📢 Thoughts on this report? Let us know!

Copy link
Copy Markdown
Collaborator

@LearningGp LearningGp left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@LearningGp LearningGp merged commit cc06dbb into agentscope-ai:main Apr 28, 2026
5 checks passed
@jujn jujn deleted the fix_1230 branch April 29, 2026 08:45
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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]:配置enableReasoning之后,agentscope没有按照agui协议返回reasoning的标准role:reasoning

3 participants