Skip to content

[Bug] pin one text messageId per assistant reply - #4068

Open
chcodex wants to merge 5 commits into
agentscope-ai:mainfrom
chcodex:fix/agui-text-message-id
Open

chcodex wants to merge 5 commits into
agentscope-ai:mainfrom
chcodex:fix/agui-text-message-id

Conversation

@chcodex

@chcodex chcodex commented Nov 8, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Fixes #4067.

AG-UI clients aggregate assistant text by messageId. Before this change the text converter derived the id from TextBlockDeltaEvent.replyId, which is the per-model-call id, so text -> tool -> text inside one assistant turn produced two assistant messages. This resolves the text id from each event's stable execution turn id (ExecutionIdentity.turnId), the same identity used by #4026 replay and #4039 live delivery.

Changes

  • TextBlockEventConverter now resolves the text message id directly from the event: event.getExecution().turnId() when present, otherwise replyId-blockId. Forwarded text therefore uses the child event's own turn id when present and falls back to replyId-blockId only when it has no execution identity.
  • Removed the AguiStreamContext turn-id state (assistantTurnId, beginAssistantTurn, endAssistantTurn, resolveTextMessageId); no text identity is carried across events in the stream context anymore.
  • AgentLifecycleEventConverter is back to its original lifecycle-only behavior and does not record text ids.
  • A closed text id is reopened with a fresh TEXT_MESSAGE_START before appending, so every text segment has a matched START / END and no START is emitted while the id is still open.
  • Reasoning messages keep a separate id namespace and never reuse the bare text id.
  • English and Chinese AG-UI docs updated.

Relation to #4026 and #4039

  • #4026 (pushed as c21d7e92a) already derives replay text ids from SessionEvent.turnId() and reasoning ids from turnId + ":reasoning".
  • #4039 (rebased and pushed as 0c4f2db20) adds AgentEventIds.turnId / textMessageId / reasoningMessageId, reading event.getExecution().turnId(), and uses turnId:reasoning for live reasoning.
  • This PR's text rule matches AgentEventIds.textMessageId exactly; on rebase the local resolver can be replaced by AgentEventIds. The startTextMessage reopen hunk still overlaps with feat(agui): hand off active runs to live frames #4039; keep either implementation when resolving.

Tests

  • mvn -o -q -pl agentscope-extensions/agentscope-extensions-protocol/agentscope-extensions-agui -am -DskipTests -Dmaven.javadoc.skip=true install
  • mvn -o -q -pl agentscope-extensions/agentscope-extensions-protocol/agentscope-extensions-agui spotless:check
  • mvn -o -q -pl agentscope-extensions/agentscope-extensions-protocol/agentscope-extensions-agui test — 489 tests, 0 failures, 0 errors.
  • New regressions: text -> tool -> text uses the same id and it equals the event execution turnId; each text segment has matched START/END; a second tool round keeps it; each assistant turn uses its own turn id; forwarded text uses the child turn id when present, falls back to block ids without execution, and never reuses the parent id; missing turn id keeps per-block fallback ids; reasoning does not reuse the bare text id.
  • Docs: npm test, npm run validate, npm run broken-links pass.

No public config, legacy flag, or opt-in/opt-out was added.

Merge order

@mintlify

mintlify Bot commented Nov 8, 2026 •

Copy link
Copy Markdown

Preview approval required

This pull request comes from a fork, so Mintlify won't build a preview until someone with write access approves commit e557970.

Approve preview

chcodex added a commit to chcodex/agentscope-java that referenced this pull request Nov 8, 2026
@jujn jujn added the P1 紧急不重要 label Nov 10, 2026

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

P1 紧急不重要

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: assistant text messageId changes across text→tool→text within one reply

2 participants