Skip to content

Python: Prefer explicit AG-UI resume payloads#6360

Open
gezw wants to merge 2 commits into
microsoft:mainfrom
gezw:codex/gezw-agui-resume-message-precedence
Open

Python: Prefer explicit AG-UI resume payloads#6360
gezw wants to merge 2 commits into
microsoft:mainfrom
gezw:codex/gezw-agui-resume-message-precedence

Conversation

@gezw
Copy link
Copy Markdown

@gezw gezw commented Jun 5, 2026

Summary

  • make explicit AG-UI resume payloads take precedence over message-derived responses
  • preserve message-derived responses when no explicit resume payload is present
  • add workflow-run regression coverage for stale message approvals

Details

run_workflow_stream() can receive resume responses from both the explicit resume payload 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.py
  • uv run --group dev ruff check packages/ag-ui/agent_framework_ag_ui/_workflow_run.py packages/ag-ui/tests/ag_ui/test_workflow_run.py
  • uv 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.py
  • uv 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.py
  • git diff --check

Copilot AI review requested due to automatic review settings June 5, 2026 14:34
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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"])
@moonbox3 moonbox3 added the python label Jun 5, 2026
@gezw
Copy link
Copy Markdown
Author

gezw commented Jun 6, 2026

@microsoft-github-policy-service agree

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

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants