Repository navigation
Python: preserve AG-UI input on failed runs and prevent duplicate snapshot messages - #9798
Open
Ran Shemtov (ranst91) wants to merge 4 commits into
Open
Ran Shemtov (ranst91) wants to merge 4 commits into
Ran Shemtov (ranst91) wants to merge 4 commits into
Conversation
Ran Shemtov (ranst91)
deployed
to
github-app-auth
October 28, 2026 14:05 — with
GitHub Actions
Active
Ran Shemtov (ranst91)
requested review from
Darren Cohen (dargilco) and
sophia-ramsey
as code owners
October 28, 2026 14:05
Ran Shemtov (ranst91)
deployed
to
github-app-auth
October 28, 2026 14:05 — with
GitHub Actions
Active
Contributor
There was a problem hiding this comment.
🟡 Changes recommended
Checkpoint persistence can lose recoverable input after session-ID rebinding and prematurely clear unresolved interrupt prompts, leaving hydration incomplete after a failure or disconnect.
2 open issues
What changed in this PR
This PR strengthens persistence in the Python AG-UI adapter so failed runs retain submitted input and differing client history does not duplicate saved messages.
Changes:
- Filter already-stored message IDs from reconciled incoming history.
- Checkpoint input before provider execution for configured stateless snapshot sessions.
- Preserve attachment filenames during multimodal snapshot normalization and add regression coverage.
| File | Description |
|---|---|
python/packages/ag-ui/tests/ag_ui/test_run.py |
Expect submitted input to survive response invalidation. |
python/packages/ag-ui/tests/ag_ui/test_run_common.py |
Test deduplication when client history differs from saved history. |
python/packages/ag-ui/tests/ag_ui/test_message_adapters.py |
Test filename preservation across normalization. |
python/packages/ag-ui/tests/ag_ui/test_endpoint.py |
Cover failed-run persistence, cancellation, media, and approval-history replay. |
python/packages/ag-ui/agent_framework_ag_ui/_run_common.py |
Exclude stored IDs from incoming history suffixes. |
python/packages/ag-ui/agent_framework_ag_ui/_message_adapters.py |
Retain filenames in normalized binary parts. |
python/packages/ag-ui/agent_framework_ag_ui/_agent_run.py |
Add an input checkpoint before provider execution. |
Review effort: Balanced
| await save_thread_snapshot( | ||
| persisted_messages=persisted_input, | ||
| state=latest_state_snapshot, | ||
| interrupt=snapshot_interrupts(), |
Comment on lines
+3721
to
+3725
| await save_thread_snapshot( | ||
| persisted_messages=persisted_input, | ||
| state=latest_state_snapshot, | ||
| interrupt=snapshot_interrupts(), | ||
| ) |
Ran Shemtov (ranst91)
deployed
to
github-app-auth
October 28, 2026 14:58 — with
GitHub Actions
Active
This branch was successfully deployed
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
This change addresses three persistence gaps in the Python AG-UI adapter:
Our original duplication case was triggered by a CopilotKit wrapper that removed historical tool messages. We fixed that wrapper separately. The reconciliation change here provides additional protection when incoming history differs from saved history.
Description & Review Guide
Existing duplicated snapshots are not rewritten. Unfinished assistant output is not committed by the input checkpoint.
Please review the checkpoint boundary, approval continuation behavior, and preservation of message identity and attachment metadata.
Validation
At commit
bf82841e7:These checks used a custom JSON snapshot store. They do not establish coverage for every storage implementation or browser/Intelligence workflow.
Related Issue
This contribution was initiated by the AG-UI team. An agreed Microsoft issue has not yet been linked.
AI Assistance
Implementation, tests, investigation, and this description were AI-assisted. Human contributor review and responsibility acknowledgement remain pending.