Python: maintenance updates - #8279
Conversation
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
There was a problem hiding this comment.
🟡 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.
There was a problem hiding this comment.
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
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
Motivation & Context
Routine maintenance.
Description & Review Guide
Related Issue
None.
Contribution Checklist
breaking changelabel (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.