Python: Fix AG-UI workflow-as-agent approval resumes - #7776
Python: Fix AG-UI workflow-as-agent approval resumes#7776Evan Mattson (moonbox3) wants to merge 7 commits into
Conversation
There was a problem hiding this comment.
Pull request overview
Adds request-scoped tool propagation and approval-resume correlation for workflows exposed as agents through AG-UI.
Changes:
- Propagates runtime tools through workflows, agents, executors, and nested workflows.
- Maps canonical AG-UI approval IDs back to workflow request aliases.
- Adds propagation and endpoint regression tests.
Reviewed changes
Copilot reviewed 7 out of 7 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
python/packages/core/tests/workflow/test_workflow_kwargs.py |
Tests tool propagation. |
python/packages/core/agent_framework/_workflows/_workflow.py |
Stores runtime tools in workflow state. |
python/packages/core/agent_framework/_workflows/_workflow_executor.py |
Forwards tools into nested workflows. |
python/packages/core/agent_framework/_workflows/_agent.py |
Accepts and forwards tools from WorkflowAgent. |
python/packages/core/agent_framework/_workflows/_agent_executor.py |
Passes tools to underlying agents. |
python/packages/ag-ui/tests/ag_ui/test_endpoint.py |
Tests workflow-as-agent approval resume. |
python/packages/ag-ui/agent_framework_ag_ui/_agent_run.py |
Adds workflow approval ownership and ID translation. |
💡 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 (1 commit(s)): 2f684c4af26f
Model: gpt-5.6-sol
Overview
The review found 3 verified inline finding(s).
Reviewed the supplied pull-request change set across correctness, security/reliability, architecture, and failure behavior.
3 verified findings remained after source verification (3 medium) across 3 files. Details are attached to the affected lines below.
Affected areas: python/packages/core/agent_framework/_workflows/_agent_executor.py, python/packages/core/agent_framework/_workflows/_workflow.py, python/packages/core/agent_framework/_workflows/_workflow_executor.py
There was a problem hiding this comment.
MAF Automated Review — Iteration 2
Result: Findings reported
Scope: 2 net-new commit(s): 260dc00c40b4, c7c402d3780a
Model: gpt-5.6-sol
Overview
The incremental changes improve workflow-agent approval correlation and add explicit cancellation cleanup, backed by endpoint coverage for direct wrapped workflows. The response-shape guards and request-ID validation preserve existing approval and declaration-only tool behavior. One lifecycle gap remains: cancellation cleanup does not reach the owning executor inside a nested workflow, so mixed approval batches can remain blocked.
Reviewed the supplied incremental change set across correctness, security/reliability, architecture, and failure behavior.
1 verified finding remained after source verification (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
|
/review |
There was a problem hiding this comment.
MAF Automated Review — Iteration 3
Result: Findings reported
Scope: 2 net-new commit(s): 11ea19d2cafa, 80a4851b2401
Model: gpt-5.6-sol
Overview
The change adds request-scoped tool propagation and recursively clears cancelled workflow requests while preserving runtime tools outside checkpointed state. The new ownership validation, signature guards, and nested cancellation tests cover the primary workflow-as-agent resume path. Two cancellation orderings remain broken: cancellation is ineffective before a cold checkpoint restore, and cancelling the last request after a sibling response has already been accepted does not resume the owning agent.
Reviewed the supplied incremental change set across correctness, security/reliability, architecture, and failure behavior.
2 verified findings remained after source verification (2 medium) across 2 files. Details are attached to the affected lines below.
Affected areas: python/packages/ag-ui/agent_framework_ag_ui/_workflow_run.py, python/packages/core/agent_framework/_workflows/_agent_executor.py
Motivation & Context
When a workflow was exposed through
AgentFrameworkAgent(workflow.as_agent()), AG-UI client tools were passed intoWorkflowAgent.run()even though the workflow adapter did not accept or propagate them. Approval resumes could therefore fail before the interrupt was surfaced, or lose the original workflow request correlation.Description & Review Guide
WorkflowAgent,Workflow,AgentExecutor, and nestedWorkflowExecutorpaths. Mark wrapped workflows as deferred approval owners and translate the canonical AG-UI tool-call ID back to the workflow request alias on resume.AgentFrameworkAgentcan now accept AG-UI client tools and complete canonical approval resumes while preserving existing native workflow behavior.Related Issue
Fixes #7707
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.