Uh oh!
There was an error while loading. Please reload this page.
Python: Avoid unchanged AG-UI predictive state snapshots - #7766
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>
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.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
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)
commented
Aug 19, 2026
@microsoft-github-policy-service agree |
Python Test Coverage Report •
Python Unit Test Overview
| ||||||||||||||||||||||||||||||
Uh oh!
There was an error while loading. Please reload this page.
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.