Skip to content

Conversation

@moonbox3
Copy link
Contributor

Motivation and Context

In the current code we're not sending the MessageSnapshotEvent at the proper time which was causing the UI to to handle weird state values, quickly showing some text and then having it disappear. These fixes were tested with the dojo app along with the getting started MAF Python scripts.

Description

Fix state problems.
Bump package to 1.0.0b251117 for a release.

Contribution Checklist

  • The code builds clean without any errors or warnings
  • The PR follows the Contribution Guidelines
  • All unit tests pass, and I have added new tests where possible
  • Is this a breaking change? If yes, add "[BREAKING]" prefix to the title of the PR.

Copilot AI review requested due to automatic review settings November 18, 2025 02:16
Copy link
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

This PR fixes state handling issues in the Python ag-ui package that were causing UI flickering - text would briefly appear and then disappear due to incorrect timing of MessageSnapshotEvent emissions and improper state context injection during agent execution.

Key Changes:

  • Fixed timing of MessagesSnapshotEvent emission to prevent incomplete snapshots that cause UI flicker
  • Improved state context injection logic to only inject on new user turns, not during mid-execution tool calls
  • Added comprehensive logging throughout the stream processing pipeline for better debugging

Reviewed Changes

Copilot reviewed 4 out of 5 changed files in this pull request and generated 3 comments.

File Description
python/packages/ag-ui/agent_framework_ag_ui_examples/agents/recipe_agent.py Added require_confirmation=False parameter to recipe agent configuration
python/packages/ag-ui/agent_framework_ag_ui/_orchestrators.py Fixed state context injection logic and MessagesSnapshotEvent timing; added extensive logging
python/packages/ag-ui/agent_framework_ag_ui/_message_adapters.py Added new agui_messages_to_snapshot_format function to normalize message format for snapshots
python/packages/ag-ui/agent_framework_ag_ui/_events.py Added text accumulation tracking and logic to skip intermediate snapshots for predictive tools; enhanced logging

@markwallace-microsoft
Copy link
Member

markwallace-microsoft commented Nov 18, 2025

Python Test Coverage

Python Test Coverage Report •
FileStmtsMissCoverMissing
packages/ag-ui/agent_framework_ag_ui
   _events.py2741096%160, 286, 305, 336, 454–455, 459, 596–597, 628
   _message_adapters.py1583379%57, 87, 95–96, 98, 102–105, 118, 200, 202–203, 205–209, 211, 213–214, 237, 239, 241–242, 244–246, 259, 261, 324, 329–330
   _orchestrators.py4033292%138, 399, 486, 553–554, 586, 653–655, 663–664, 670–671, 675–676, 690–691, 738–740, 747, 750–751, 754–757, 759–761, 834, 839
TOTAL14988220785% 

Python Unit Test Overview

Tests Skipped Failures Errors Time
2039 127 💤 0 ❌ 0 🔥 39.446s ⏱️

@moonbox3 moonbox3 added this pull request to the merge queue Nov 18, 2025
@moonbox3 moonbox3 removed this pull request from the merge queue due to a manual request Nov 18, 2025
@markwallace-microsoft markwallace-microsoft added the documentation Improvements or additions to documentation label Nov 18, 2025
@moonbox3 moonbox3 merged commit 1f0ffc1 into microsoft:main Nov 18, 2025
25 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation Improvements or additions to documentation python

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants