Skip to content

Python: retain AG-UI snapshot history and failed input turns - #1

Open
ranst91 wants to merge 3 commits into
test/pni711-upstream-baselinefrom
fix/ag-ui-snapshot-reconciliation
Open

ranst91 wants to merge 3 commits into
test/pni711-upstream-baselinefrom
fix/ag-ui-snapshot-reconciliation

Conversation

@ranst91

@ranst91 ranst91 commented Oct 27, 2026 •

Copy link
Copy Markdown
Owner

Motivation & Context

Client-replayed AG-UI history can differ from stored assistant output. When the contiguous overlap ends at that difference, later user records can be appended a second time despite retaining their original IDs. Separately, a downstream provider failure before the first result/terminal checkpoint loses the received user turn, including attachments.

This PR is ready for review in the contributor fork. Its base branch pins Microsoft main 10a94cf73 (full SHA available on the base commit); it does not request an upstream merge or represent published support. Human contributor review and upstream issue agreement remain pending.

Description & Review Guide

  • What are the major changes? Filter already-stored message IDs from the incoming suffix while keeping backend history authoritative. Checkpoint accepted input before stateless provider execution. Preserve original filenames when converting media into the existing binary snapshot representation.
  • What is the impact of these changes? Approved/declined tool results and later user messages retain their occurrence/order across replay gaps. Provider errors and disconnects retain accepted user input without committing unfinalized assistant output. Provider-managed service-session saves retain their existing terminal-only contract. Each configured stateless run adds one input checkpoint. This does not repair pre-existing duplicated snapshots.
  • What do you want reviewers to focus on? Backend authority and original ordering in reconciliation; the input/output checkpoint boundary; filename normalization across successive turns. No public API, dependency, protocol-version, importer, or release changes.

Five initial regressions failed on the fresh upstream baseline. The full AG-UI unit suite passes (1,787 tests), with existing dependency/deprecation warnings; source Pyright reports zero errors/warnings, and changed-file Ruff/format checks pass. Added regressions cover mixed frontend/native completed/pending history, native approved/declined continuation, fresh/existing failed-media turns, and filename normalization.

Real-provider controls use the configured CopilotKit showcase agent factories through FastAPI, OpenAI Chat Completions (gpt-5-mini, multimodal gpt-4o-mini), and the same custom JSON implementation of AGUIThreadSnapshotStore in isolated storage. All four original image/document/audio/video inputs survive downstream rejection with exact bytes/MIME/filename. Approved/declined frontend results, approved/declined native results, and a newly issued native pending approval survive cold ThreadSnapshotSession.open/hydrate_events, with unique message IDs. This is adapter snapshot evidence, not FileSessionStore/MessagePack, browser parity, provider-managed session mode, or publication certification.

Related Issue

PNI-711. No upstream issue agreement is asserted. Separate protocol/media compatibility work remains Microsoft #9378; this patch preserves filenames in the existing storage format without taking over that work.

AI Assistance

  • No material AI assistance was used.
  • This is an AI-assisted contribution prepared for human review; personal contributor review and responsibility acknowledgement remain pending.

AI assistance details: diagnosis, implementation, regression tests, local provider checks, and this description were prepared by Codex. This fork PR does not attest that the human has reviewed it.

Contribution Checklist

  • Changed source passes static analysis and formatting checks.
  • All AG-UI unit tests pass, with new regression tests.
  • Human review and upstream contribution prerequisites are complete.
  • This PR links to an agreed upstream issue with no competing open PR.
  • This is not a breaking change.

Fork CI limitation: the DevFlow/community team checks fail because github-token is not supplied, and the label job fails because token/opts.auth is missing. These are repository automation configuration failures, not test failures. Local validation above applies to head bf82841e737aa617eb05414de4a4a68217fa5e05.

@ranst91
ranst91 marked this pull request as ready for review October 27, 2026 15:54

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant