Python: Match AG-UI approval responses to requested arguments#6376
Merged
Conversation
Contributor
Python Test Coverage Report •
Python Unit Test Overview
|
|||||||||||||||||||||||||||||||||||||||||||||
Contributor
There was a problem hiding this comment.
Pull request overview
This PR tightens AG-UI human-approval handling so that an approval response only resumes/executes the exact function call that was originally presented for review (matching on function name and canonicalized arguments), preventing argument tampering during approval.
Changes:
- Canonicalize function-call arguments and store them alongside the function name in the pending-approvals registry.
- Reject (ignore) approval responses that don’t match the pending request’s function name + canonical arguments, preserving the pending approval for a legitimate retry.
- Add regression tests for both agent and workflow approval flows when arguments are changed between request and response.
Reviewed changes
Copilot reviewed 5 out of 6 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| python/uv.lock | Bumps azure-ai-projects dependency version in the Python lockfile. |
| python/packages/ag-ui/tests/ag_ui/test_workflow_run.py | Adds workflow-stream regression test ensuring argument-mismatched approvals don’t resume execution. |
| python/packages/ag-ui/tests/ag_ui/test_agent_wrapper_comprehensive.py | Adds agent-wrapper regression test ensuring argument-mismatched approvals don’t execute and pending approval remains. |
| python/packages/ag-ui/agent_framework_ag_ui/_workflow_run.py | Adds approval response matching for workflow interrupt/resume response coercion. |
| python/packages/ag-ui/agent_framework_ag_ui/_utils.py | Introduces canonical argument serialization helper for stable comparison. |
| python/packages/ag-ui/agent_framework_ag_ui/_agent_run.py | Extends pending approval tracking to include canonical arguments and enforces argument match on approval responses. |
Comments suppressed due to low confidence (1)
python/packages/ag-ui/agent_framework_ag_ui/_agent_run.py:461
- The
pending_approvalsparameter docstring is now inaccurate: the registry values are no longer just function names (they can include canonicalized arguments). This mismatch can mislead future edits and reviewers.
pending_approvals: dict[str, _PendingApprovalEntry] | None = None,
thread_id: str = "",
) -> list[Content]:
"""Execute approved function calls and replace approval content with results.
42c5d4c to
e130bc5
Compare
eavanvalkenburg
approved these changes
Jun 8, 2026
TaoChenOSU
approved these changes
Jun 8, 2026
4 tasks
This was referenced Jun 10, 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 and Context
AG-UI approvals should resume the exact function call that was presented for review. This change tightens approval matching so approval responses are accepted only when they match the pending request's function name and canonical arguments.
Description
Contribution Checklist