Python: fix(ag-ui): preserve streamed text message id#6269
Merged
eavanvalkenburg merged 2 commits intoJul 8, 2026
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
Note
Copilot was unable to run its full agentic suite in this review.
Updates message snapshot generation so that, when both tool calls and streamed text are present, the streamed text message keeps the original flow.message_id while the tool-call message gets a different ID.
Changes:
- Adjust
_build_messages_snapshotmessage ID assignment to preserve streamed text message IDs in mixed tool-call/text snapshots. - Add a regression test covering the mixed tool-call + text case to ensure IDs are preserved/isolated correctly.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| python/packages/ag-ui/agent_framework_ag_ui/_agent_run.py | Changes assistant/tool-call vs assistant/text message ID selection logic in snapshots. |
| python/packages/ag-ui/tests/ag_ui/test_run.py | Adds a test asserting streamed text message ID is preserved when tool calls are also present. |
Contributor
Python Test Coverage Report •
Python Unit Test Overview
|
||||||||||||||||||||||||||||||
moonbox3
approved these changes
Jun 5, 2026
Contributor
|
@cyphercodes thanks for the fix. Please make sure you accept the CLA. |
Contributor
|
@cyphercodes quick ping on this - please accept the CLA, so we can get the fix in. Thanks. |
|
@cyphercodes it would be great to have this completed. Thanks ! |
Contributor
Author
|
@microsoft-github-policy-service agree company="CypherCodes" |
Contributor
Author
|
CLA completed now; the |
eavanvalkenburg
approved these changes
Jul 8, 2026
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.
Motivation and Context
Fixes #6266.
Mixed AG-UI snapshots with both pending tool calls and streamed trailing text were assigning the streamed text
message_idto the tool-call-only assistant message. The text message then received a generated ID, which broke reconciliation for the already-streamed text.Description
When a snapshot contains both tool calls and accumulated text, this changes the tool-call-only assistant message to use a generated ID and preserves
flow.message_idfor the text assistant message.A regression test covers the mixed tool-call/text snapshot and verifies that the text message keeps the streamed message ID while the tool-call message remains distinct.
Contribution Checklist
Validation:
uv run --group dev pytest packages/ag-ui/tests/ag_ui/test_run.py::TestBuildMessagesSnapshot -quv run --group dev poe syntax -P ag-uiuv run --group dev poe pyright -P ag-uiuv run --group dev poe test -P ag-ui