Skip to content

Python: Fix AG-UI approval thread aliases#6908

Open
godququ5-code wants to merge 1 commit into
microsoft:mainfrom
godququ5-code:godququ5/issue-6894
Open

Python: Fix AG-UI approval thread aliases#6908
godququ5-code wants to merge 1 commit into
microsoft:mainfrom
godququ5-code:godququ5/issue-6894

Conversation

@godququ5-code

Copy link
Copy Markdown

Summary

  • Register AG-UI pending approval requests under both the original client thread id and the provider-advertised conversation id.
  • Store aliases on one shared pending-approval entry so a successful approval consumes every alias and prevents replay.
  • Add a two-turn regression covering both client-thread and provider-conversation resume ids.

Fixes #6894

Root cause

For stateful providers such as Foundry, AG-UI can receive a request with a stable client thread id, then stream a provider conversation id back to the caller. Pending approval requests were registered only under the post-stream provider id, so clients that resumed with the original client thread id could not match the pending approval and the tool was never executed.

Test plan

  • uv run pytest packages/ag-ui/tests/ag_ui/test_approval_thread_id_mismatch.py packages/ag-ui/tests/ag_ui/test_agent_wrapper_comprehensive.py -k "approval" -q
  • cd packages/ag-ui && uv run poe test
  • cd packages/ag-ui && uv run poe syntax
  • cd packages/ag-ui && uv run poe pyright

Copilot AI review requested due to automatic review settings July 3, 2026 19:40
@giles17 giles17 added the python Usage: [Issues, PRs], Target: Python label Jul 3, 2026
@github-actions github-actions Bot changed the title Fix AG-UI approval thread aliases Python: Fix AG-UI approval thread aliases Jul 3, 2026

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

This PR fixes AG-UI approval resolution for stateful providers (e.g., Foundry) where the provider-advertised conversation_id can differ from the client-supplied thread_id, causing pending approvals to be unresolvable on resume and leading to missing tool outputs.

Changes:

  • Register each pending approval under both the original client thread id and the provider conversation id (as aliases to the same registry entry).
  • Consume/remove all aliases when an approval response is validated to prevent replay across either id.
  • Add a regression test that resumes approvals using either id and verifies replay prevention.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
python/packages/ag-ui/agent_framework_ag_ui/_agent_run.py Adds alias-aware pending-approval registration/removal and updates eviction + approval consumption to operate on shared alias entries.
python/packages/ag-ui/tests/ag_ui/test_approval_thread_id_mismatch.py New regression test covering approval resolution via client thread id vs provider conversation id and preventing replay via the alternate id.

@godququ5-code

Copy link
Copy Markdown
Author

@microsoft-github-policy-service agree

@godququ5-code godququ5-code marked this pull request as ready for review July 3, 2026 19:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

python Usage: [Issues, PRs], Target: Python

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Python: [Bug]: AG-UI: 'No tool output found' on Foundry provider

3 participants