Python: Prefer explicit AG-UI resume payloads#6360
Open
gezw wants to merge 2 commits into
Open
Conversation
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 ensures that explicit resume payload responses take precedence over any responses inferred from incoming messages (e.g., stale function_approvals), and adds a regression test for that behavior.
Changes:
- Add
_merge_workflow_response_sources()to merge resume/message-derived responses with resume taking precedence. - Update
run_workflow_stream()to use the new merge behavior. - Add a test ensuring explicit resume approval responses override stale message approvals.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| python/packages/ag-ui/agent_framework_ag_ui/_workflow_run.py | Merges response sources so explicit resume payloads override message-derived responses. |
| python/packages/ag-ui/tests/ag_ui/test_workflow_run.py | Adds regression test covering precedence of resume interrupts over function_approvals in messages. |
Comment on lines
+1424
to
+1426
| text_deltas = [event.delta for event in resumed_events if event.type == "TEXT_MESSAGE_CONTENT"] | ||
| assert any("rejected" in delta for delta in text_deltas) | ||
| assert not any("approved" in delta for delta in text_deltas) |
Comment on lines
+1380
to
+1385
| first_events = [ | ||
| event async for event in run_workflow_stream({"messages": [{"role": "user", "content": "go"}]}, workflow) | ||
| ] | ||
| first_finished = [event for event in first_events if event.type == "RUN_FINISHED"][0].model_dump() | ||
| interrupt_payload = cast(list[dict[str, Any]], first_finished.get("interrupt")) | ||
| interrupt_value = cast(dict[str, Any], interrupt_payload[0]["value"]) |
Author
|
@microsoft-github-policy-service agree |
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.
Summary
Details
run_workflow_stream()can receive resume responses from both the explicitresumepayload and from prior AG-UI messages. When both sources contain an entry for the same pending request id, the explicit resume payload should be treated as the caller's current decision and should not be overwritten by stale message history.This change centralizes the merge behavior so message-derived responses are used as a fallback and explicit resume values win on conflicts.
Validation
From
python/:uv run --group dev pytest -q --disable-warnings packages/ag-ui/tests/ag_ui/test_workflow_run.pyuv run --group dev ruff check packages/ag-ui/agent_framework_ag_ui/_workflow_run.py packages/ag-ui/tests/ag_ui/test_workflow_run.pyuv run --group dev ruff format --check packages/ag-ui/agent_framework_ag_ui/_workflow_run.py packages/ag-ui/tests/ag_ui/test_workflow_run.pyuv run --group dev python -m py_compile packages/ag-ui/agent_framework_ag_ui/_workflow_run.py packages/ag-ui/tests/ag_ui/test_workflow_run.pygit diff --check