Python: Avoid unchanged AG-UI predictive state snapshots - #7766
Merged
Evan Mattson (moonbox3) merged 2 commits intoAug 20, 2026
Merged
Conversation
Only emit the coalesced snapshot when predictive updates were actually pending or a deterministic state update was returned. Assisted-by: Codex <codex@openai.com>
ALEX LILUZ (alexliluz)
had a problem deploying
to
github-app-auth
August 19, 2026 13:48 — with
GitHub Actions
Error
ALEX LILUZ (alexliluz)
temporarily deployed
to
github-app-auth
August 19, 2026 13:48 — with
GitHub Actions
Inactive
ALEX LILUZ (alexliluz)
temporarily deployed
to
github-app-auth
August 19, 2026 13:48 — with
GitHub Actions
Inactive
Contributor
There was a problem hiding this comment.
Pull request overview
Note
Copilot was unable to run its full agentic suite in this review.
This PR adjusts when _emit_tool_result_common emits STATE_SNAPSHOT events so that a configured predictive state handler only triggers a snapshot when it actually has pending predictive updates, and adds tests to lock in that behavior.
Changes:
- Prevent emitting unchanged
STATE_SNAPSHOTevents when a predictive handler is present but has no pending updates. - Add tests covering predictive handler behavior with/without pending updates.
- Keep existing snapshot behavior for explicit tool
state_updateresults.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 5 comments.
| File | Description |
|---|---|
| python/packages/ag-ui/agent_framework_ag_ui/_run_common.py | Gate snapshot emission on predictive handler having pending updates (not merely being configured). |
| python/packages/ag-ui/tests/ag_ui/test_run_common.py | Add regression tests ensuring snapshots are emitted only when predictive updates are pending/applied. |
💡 Add a code-review agent skill for context-aware, tailored reviews. Learn more in the docs.
ALEX LILUZ (alexliluz)
temporarily deployed
to
github-app-auth
August 19, 2026 13:50 — with
GitHub Actions
Inactive
Use the handler streaming API to create pending state and narrow snapshot events by their concrete type. Assisted-by: Codex <codex@openai.com>
ALEX LILUZ (alexliluz)
temporarily deployed
to
github-app-auth
August 19, 2026 13:52 — with
GitHub Actions
Inactive
Contributor
Author
|
@microsoft-github-policy-service agree |
ALEX LILUZ (alexliluz)
marked this pull request as ready for review
August 19, 2026 14:26
ALEX LILUZ (alexliluz)
requested review from
chetantoshniwal,
Giles Odigwe (giles17) and
Evan Mattson (moonbox3)
as code owners
August 19, 2026 14:26
ALEX LILUZ (alexliluz)
temporarily deployed
to
github-app-auth
August 19, 2026 14:26 — with
GitHub Actions
Inactive
Evan Mattson (moonbox3)
approved these changes
Aug 20, 2026
Contributor
Python Test Coverage Report •
Python Unit Test Overview
|
||||||||||||||||||||||||||||||
This was referenced Aug 22, 2026
Merged
This was referenced Aug 24, 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 & Context
When
predict_state_configis enabled, every tool result currently emits a fullStateSnapshotEvent, even when the completed tool did not produce a predictive update. The handler object is truthy regardless of whetherpending_state_updatesis empty, so unrelated tools resend unchanged state and can trigger unnecessary client rendering.Description & Review Guide
state_updateresults retain the existing single-snapshot behavior.apply_pending_updates()is the preferred boundary for distinguishing configured prediction from an actual state change.Related Issue
Fixes #7490
No other open PR is linked to this issue.
Contribution Checklist
breaking changelabel (or add "[BREAKING]" to the title prefix, before or after any language prefix) — a workflow keeps the label and title prefix in sync automatically.