Python: Fix AG-UI workflow handoff replay results#7102
Open
moonbox3 wants to merge 4 commits into
Open
Conversation
Decisions: - Reconcile finalized function results only for call IDs exposed in the current run, and skip results already emitted or never exposed. - Treat message-derived function results as workflow responses only when their IDs match pending interrupts. Files: - Updated _workflow_run.py reconciliation and resume filtering. - Added runner and public two-turn handoff acceptance coverage. - Expanded finalized-response call-ID, privacy, and deduplication tests. Verification: - uv run poe test -P ag-ui - uv run poe syntax -P ag-ui -C - uv run poe pyright -P ag-ui - uv run poe test-typing -P ag-ui Notes: - No blockers. The handoff sample remains unchanged; local PRD and issue files are not included.
Contributor
There was a problem hiding this comment.
Pull request overview
This PR fixes AG-UI workflow handoff replay by ensuring tool-call transcripts remain provider-valid across turns when a workflow’s synthetic handoff result is only present in the finalized response (not in the streamed event sequence). It updates the workflow stream runner to reconcile finalized tool results for tool calls that were actually exposed during the current run, while preserving explicit workflow resume semantics.
Changes:
- Reconcile finalized
function_resultitems for tool calls exposed during the run, emitting missingTOOL_CALL_RESULTevents without re-emitting tool calls/results. - Restrict message-derived workflow interrupt responses to only those matching currently pending workflow interrupts (avoids replayed history being treated as a resume).
- Add regression coverage: runner-level tests for finalized-result reconciliation and an end-to-end two-turn handoff replay test using a real
HandoffBuilderworkflow andAGUIChatClient.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| python/packages/ag-ui/agent_framework_ag_ui/_workflow_run.py | Adds finalized-result reconciliation for exposed tool calls and tightens interrupt-response extraction to pending-only. |
| python/packages/ag-ui/tests/ag_ui/test_workflow_run.py | Expands runner tests to verify correct emission/deduplication and call-id matching for finalized tool results. |
| python/packages/ag-ui/tests/ag_ui/test_handoff_replay.py | Adds end-to-end acceptance tests validating replayable handoff transcripts across a second turn. |
Contributor
Python Test Coverage Report •
Python Unit Test Overview
|
||||||||||||||||||||||||||||||
eavanvalkenburg
approved these changes
Jul 14, 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
AG-UI-hosted handoff workflows expose their internal handoff function calls as standard tool events, but the matching synthetic handoff result can appear only in the participant's finalized response. Without that result in the AG-UI stream, an outer
AgentusingAGUIChatClientrecords an orphaned function call and replays provider-invalid history on the next turn. OpenAI then rejects the request with a missing tool output error.Description & Review Guide
Related Issue
Fixes #6981
No other open PR was found for this issue.
Contribution Checklist
breaking changelabel (or add "[BREAKING]" to the title prefix, before or after the language prefix) — a workflow keeps the label and title prefix in sync automatically.