Python: Defer provider-injected approvals to in-run execution - #7410
Merged
eavanvalkenburg merged 2 commits intoJul 30, 2026
Merged
Conversation
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: 1ee1d250-d1e2-4c6f-8c36-aae0d94fe7a1
eavanvalkenburg
temporarily deployed
to
github-app-auth
July 29, 2026 20:11 — with
GitHub Actions
Inactive
eavanvalkenburg
temporarily deployed
to
github-app-auth
July 29, 2026 20:11 — with
GitHub Actions
Inactive
eavanvalkenburg
marked this pull request as ready for review
July 29, 2026 20:12
eavanvalkenburg
temporarily deployed
to
github-app-auth
July 29, 2026 20:12 — with
GitHub Actions
Inactive
Contributor
Python Test Coverage Report •
Python Unit Test Overview
|
||||||||||||||||||||||||||||||
Contributor
There was a problem hiding this comment.
Pull request overview
This PR fixes an AG-UI transport ordering bug where approval responses were being resolved (and approved tool calls executed) before agent.run() starts, meaning tools injected by ContextProvider.before_run were missing from the static tool map and could be incorrectly turned into transport-level failures. The change defers provider-injected approvals to in-run ToolApprovalMiddleware execution while still executing approvals for statically-known tools.
Changes:
- Update AG-UI approval resolution to execute only approved tool calls that exist in the static tool map, leaving provider-injected approvals in the message stream for in-run middleware handling.
- Add a full pause → approve → resume regression test to ensure a provider-injected, approval-gated tool executes exactly once and emits exactly one
TOOL_CALL_RESULT. - Update AG-UI package notes and the function-calling-loop spec to document the provider-injected approval deferral behavior.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| python/packages/ag-ui/agent_framework_ag_ui/_agent_run.py | Partitions approved responses into statically-executable vs deferred; only executes the former during transport approval resolution. |
| python/packages/ag-ui/tests/ag_ui/test_endpoint.py | Adds regression coverage for provider-injected approval deferral and in-run execution on resume. |
| python/packages/ag-ui/AGENTS.md | Documents that approvals for tools injected during before_run are deferred to in-run approval middleware. |
| docs/specs/004-python-function-calling-loop.md | Updates the spec’s coverage matrix and checklist to include provider-injected approval deferral/execution semantics. |
TaoChenOSU
approved these changes
Jul 29, 2026
Drop the forged-approval test that was stripped by pending-approval validation; the real pause-approve-resume regression remains the authoritative provider-injected coverage. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: 1ee1d250-d1e2-4c6f-8c36-aae0d94fe7a1
eavanvalkenburg
temporarily deployed
to
github-app-auth
July 30, 2026 05:33 — with
GitHub Actions
Inactive
eavanvalkenburg
enabled auto-merge
July 30, 2026 05:39
moonbox3
approved these changes
Jul 30, 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 resolves approval responses before context providers run. A tool injected during
before_runis thereforemissing from the transport's static tool map and an approved call can be rejected or fail before the tool exists.
Description & Review Guide
ToolApprovalMiddleware.before_runregisters them.Related Issue
Fixes #7043
Contribution Checklist
breaking changelabel (or add "[BREAKING]" to the title prefix, before or after any language prefix) — a workflow keeps the label and title prefix in sync automatically.