Skip to content

fix(agui): use unique message IDs for discontinuous text segments - #3010

Open
ZHCHJ888 wants to merge 2 commits into
agentscope-ai:mainfrom
ZHCHJ888:fix/agui-text-segment-ids
Open

fix(agui): use unique message IDs for discontinuous text segments#3010
ZHCHJ888 wants to merge 2 commits into
agentscope-ai:mainfrom
ZHCHJ888:fix/agui-text-segment-ids

Conversation

@ZHCHJ888

@ZHCHJ888 ZHCHJ888 commented Sep 6, 2026

Copy link
Copy Markdown
Contributor

AgentScope-Java Version

2.0.3-SNAPSHOT

Description

Fixes #2988.

When a single model call emits text, then a tool call, then more text, the core previously reused the same text block ID. The AG-UI adapter consequently reused an already-ended message ID and emitted the second TEXT_MESSAGE_CONTENT without a matching TEXT_MESSAGE_START.

This change:

  • assigns a distinct block ID to each contiguous text segment within a model call (text, text-2, ...);
  • derives a distinct AG-UI message ID for subsequent segments while preserving the original reply ID for the first segment;
  • adds core and AG-UI regression tests for the text -> tool call -> text sequence.

Testing

  • ReActAgentNewLoopReplyTest: 14 passed, 0 failed.
  • AG-UI module test suite: 500 passed, 0 failed.
  • Core module full suite: 2,319 tests; 0 failures, 2 environment errors, 8 skipped. The two errors are Windows symlink-creation tests that require privileges unavailable on this host.
  • GracefulShutdownTest: 50 passed independently after an unrelated suite-order state leak was observed during an exclusion rerun.

Checklist

  • Code passes Spotless checks.
  • Relevant core and AG-UI tests pass.
  • Javadoc is complete and clear.
  • Documentation changes are not required for this internal lifecycle fix.
  • The pull request is ready for review.

@jujn

jujn commented Sep 6, 2026

Copy link
Copy Markdown
Collaborator

不只是 text,reasoning 也有同样的问题哈

@ZHCHJ888

ZHCHJ888 commented Sep 6, 2026

Copy link
Copy Markdown
Contributor Author

不只是 text,reasoning 也有同样的问题哈

收到老师,那我按相同思路为连续 reasoning 段生成独立的 blockId,并补充回归测试,预计改动量不大,感谢您审阅和提醒

@codecov

codecov Bot commented Sep 6, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 89.06250% with 7 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
.../core/agui/adapter/strategy/AguiStreamContext.java 83.33% 0 Missing and 6 partials ⚠️
...e/src/main/java/io/agentscope/core/ReActAgent.java 94.73% 0 Missing and 1 partial ⚠️

📢 Thoughts on this report? Let us know!

@ZHCHJ888

ZHCHJ888 commented Sep 6, 2026

Copy link
Copy Markdown
Contributor Author

@jujn 老师,我补齐 reasoning 场景并增加了相关回归测试了,等您有空能麻烦再帮忙看一下吗

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]:模型在工具调用前后夹带文本时,TEXT_MESSAGE_START/END 配对错乱,客户端报 "No active text message found with ID"

2 participants