Skip to content

Python: maintenance updates - #8279

Draft
Evan Mattson (moonbox3) wants to merge 8 commits into
microsoft:mainfrom
moonbox3:fix/python-agui-tool-execution-enforcement
Draft

Python: maintenance updates#8279
Evan Mattson (moonbox3) wants to merge 8 commits into
microsoft:mainfrom
moonbox3:fix/python-agui-tool-execution-enforcement

Conversation

@moonbox3

Copy link
Copy Markdown
Contributor

Motivation & Context

Routine maintenance.

Description & Review Guide

  • What are the major changes? Internal updates.
  • What is the impact of these changes? Maintenance improvements.
  • What do you want reviewers to focus on? General correctness.

Related Issue

None.

Contribution Checklist

  • The code builds clean without any errors or warnings
  • All unit tests pass, and I have added new tests where possible
  • The PR follows the Contribution Guidelines
  • This PR is linked to an issue and there is no other open PR for this issue (see Related Issue above).
  • This is not a breaking change. If it is a breaking change, add the breaking change label (or add "[BREAKING]" to the title prefix, before or after any language prefix) — a workflow keeps the label and the title prefix in sync automatically.

Decisions:\n- Build adapter-owned execution middleware in canonical client, Agent, run, and applicable context-provider order without deduplicating configured entries.\n- Keep MiddlewareFailure fatal during approved local execution and expose inner Agent middleware through manual A2UI wrappers.\n\nFiles:\n- Update AG-UI approval execution and A2UI delegation.\n- Add plain, manual A2UI, automatic A2UI, and direct Agent.run policy regressions.\n- Document approval consent versus authorization.\n\nNext iteration:\n- Reuse the effective function middleware preparation for A2UI mixed tool batches in local issue 002.\n\nCo-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>\nCopilot-Session: 55cc19bf-978f-4ce7-9059-ca4146d77244
Key decisions: preserve canonical middleware ordering, propagate MiddlewareFailure as fatal, and delegate inner Agent middleware through A2UI wrappers.

Files changed: AG-UI approval runner, A2UI agent wrapper, endpoint regressions, and AG-UI package guidance.

Next iteration: local issue 002 can reuse the effective function middleware preparation for mixed A2UI tool batches.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot-Session: 55cc19bf-978f-4ce7-9059-ca4146d77244
Decisions:
- Reuse the approval-resume effective function middleware preparation for A2UI server-tool siblings, preserving canonical client, Agent, run, bundle, and context-provider order without deduplication.
- Forward function_invocation_kwargs as execution context and keep MiddlewareFailure fatal before rendering.

Files:
- Update the A2UI mixed-batch executor and shared preparation typing.
- Add real endpoint denial controls plus middleware composition, session, and invocation-context regressions.
- Document mixed-batch enforcement in AG-UI package guidance.

Next iteration:
- Local issue 003 can add the invocation-disabled approval-resume gate and safe retry behavior.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot-Session: ef1276d0-4856-4276-84da-379b8d1e5d53
Decisions:
- Gate claimed local approvals against the current function-invocation switch before execution and preserve their original authority deadline for explicit retry.
- Keep hidden auto-approved siblings server-resumable so releasing a mixed local batch does not fabricate a new client decision requirement.

Files:
- Update AG-UI approval execution and lifecycle claim recovery.
- Add plain, wrapped, snapshot, repeated-block, multi-grant, rejection, cancellation, and retention regressions.
- Document disabled-resume behavior in AG-UI package guidance.

Blocker / next iteration:
- Root-level function-loop mapping and the local issue move remain blocked by the workspace access boundary; local issue 004 follows after those artifacts are reachable.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot-Session: de26b7f7-490f-46a5-afd6-98d9fb231c3d
Decisions:
- Settle and project valid rejections and cancellations while invocation-disabled grants retain their original pending authority.
- Admit retained terminal siblings only for active, distinct occurrences, preserving replacement-generation binding and terminal-only hosted replay behavior.
- Reproject completed sibling results without re-executing their effects when an unfinished grant is retried.

Files:
- Update AG-UI resume normalization, disabled mixed-batch projection, snapshot retirement, and retained-result replay.
- Add endpoint regressions for repeated blocked mixed decisions, middleware observation, snapshot state, and completed siblings.
- Document mixed disabled-resume behavior in AG-UI package guidance.

Blocker / next iteration:
- Root-level function-loop scenario mapping and moving local issue 004 to issues/done remain blocked by the workspace access boundary.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

Copilot-Session: 8c59c982-8ccc-4d88-ae9f-b3e16ed7434d
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot-Session: 374ec67a-1a47-42d9-a5f9-70f29be29950
Copilot AI balanced review requested due to automatic review settings September 11, 2026 04:00
@agent-framework-automation agent-framework-automation Bot added documentation Usage: [Issues, PRs], Target: documentation in the code base and learn docs python Usage: [Issues, PRs], Target: Python labels Sep 11, 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.

🟡 Changes recommended

A2UI preparation and reconstructed streaming history have unresolved correctness issues, and required boundary coverage is missing.

Once you've addressed the issues Copilot identified, you can request another Copilot review.

Pull request overview

Introduces provider-aware tool execution for AG-UI approvals and A2UI mixed batches while preserving lifecycle authority and execution budgets.

Changes:

  • Adds reusable core preparation for adapter-owned tool execution.
  • Strengthens approval retry, retention, and disabled-invocation handling.
  • Adds regression coverage, specifications, and an ADR.
File summaries
File Description
python/packages/core/AGENTS.md Documents prepared execution behavior.
python/packages/core/agent_framework/_tools.py Executes declaration-only siblings through the core loop.
python/packages/core/agent_framework/_agents.py Adds prepared session and function execution contexts.
python/packages/ag-ui/tests/ag_ui/test_endpoint.py Tests policy preservation and approval retries.
python/packages/ag-ui/tests/ag_ui/test_approval_lifecycle.py Tests retention-preserving claim recovery.
python/packages/ag-ui/tests/ag_ui/test_a2ui.py Tests middleware ordering and shared budgets.
python/packages/ag-ui/AGENTS.md Documents new approval invariants.
python/packages/ag-ui/agent_framework_ag_ui/_approval_lifecycle.py Extends lifecycle retention and resume tracking.
python/packages/ag-ui/agent_framework_ag_ui/_agent_run.py Integrates prepared approval execution.
python/packages/ag-ui/agent_framework_ag_ui/_a2ui/_agent.py Moves mixed-batch sibling execution into core.
docs/specs/004-python-function-calling-loop.md Updates normative behavior and test mapping.
docs/decisions/0041-python-adapter-tool-execution.md Records the architectural approach.
Review details

Suppressed comments (1)

docs/decisions/0041-python-adapter-tool-execution.md:54

  • The PR description characterizes this as routine maintenance and internal updates, but the change introduces a new private core preparation handoff, alters function-loop behavior, and adds an ADR requiring engineering-manager and architect review. Update the PR description and review guide to disclose the architectural and approval-execution changes so reviewers can assess the stated policy, lifecycle, and compatibility risks.
The extra private handoff requires coverage for context reuse and wrong-agent/session rejection. The
mixed-declaration option must remain opt-in so ordinary function-loop behavior does not change.
Responsible engineering-manager and architect review is required before this proposed ADR is accepted.
  • Files reviewed: 12/12 changed files
  • Comments generated: 4
  • Review effort level: Balanced

💡 Add a code-review agent skill for context-aware, tailored reviews. Learn more in the docs.

Comment thread python/packages/ag-ui/agent_framework_ag_ui/_a2ui/_agent.py Outdated
Comment thread python/packages/ag-ui/agent_framework_ag_ui/_agent_run.py Outdated
Comment thread docs/decisions/0041-python-adapter-tool-execution.md Outdated
Comment thread python/packages/core/agent_framework/_agents.py Outdated

@github-actions github-actions Bot 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.

MAF Automated Review — Iteration 1

Result: Findings reported
Scope: full PR (6 commit(s)): 2cfbd1348e49, e632fa4a5d9d, 910ff9b78c4c, 701574c33c81, 316052d05fb5, b6aa11732cbe
Model: gpt-5.6-sol-fast

Overview

The PR moves adapter-owned approval execution onto core's prepared provider context and adds strong coverage for middleware ordering, invocation disablement, retry deduplication, and A2UI call-budget sharing. The preparation handoff is agent/session-bound and one-use, and policy-denial tests show that approval does not bypass function middleware. Two lifecycle edges remain: a fatal middleware escape can strand sibling authority indefinitely, and retained retry validation incorrectly rejects distinct occurrences that reuse a provider call ID.

Reviewed the supplied pull-request change set across correctness, security/reliability, architecture, and failure behavior.
2 verified findings remained after source verification (1 high, 1 medium) across 1 file. Details are attached to the affected lines below.

Affected areas: python/packages/ag-ui/agent_framework_ag_ui/_agent_run.py

Comment thread python/packages/ag-ui/agent_framework_ag_ui/_agent_run.py
Comment thread python/packages/ag-ui/agent_framework_ag_ui/_agent_run.py Outdated
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot-Session: 374ec67a-1a47-42d9-a5f9-70f29be29950
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot-Session: 374ec67a-1a47-42d9-a5f9-70f29be29950
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation Usage: [Issues, PRs], Target: documentation in the code base and learn docs python Usage: [Issues, PRs], Target: Python

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants