Uh oh!
There was an error while loading. Please reload this page.
Python: Refactor workflow as agent pending request handling - #6259
Conversation
There was a problem hiding this comment.
Pull request overview
This PR refactors Python workflow-as-agent “pending request” handling so tool-approval flows (FunctionApprovalRequest/Response) round-trip correctly across WorkflowAgent, AgentExecutor, and the Foundry ResponsesHostServer HTTP pipeline. It also introduces a Workflow.status property to expose run-level state transitions.
Changes:
- Add
Workflow.status(mirrors emitted status events) and new tests covering status transitions, including pending-request scenarios. - Update
WorkflowAgent/AgentExecutorto route tool-approval requests viarequest_infousing the underlying approval request id (so pending request IDs match what the caller echoes back). - Update Foundry hosting response conversion to persist approval requests and rehydrate them when converting
mcp_approval_responseitems; add end-to-end hosting tests for workflow agents with approvals.
Reviewed changes
Copilot reviewed 9 out of 10 changed files in this pull request and generated 5 comments.
Show a summary per file
| File | Description |
|---|---|
| python/samples/02-agents/tools/function_tool_with_approval.py | Disables the streaming demo invocation in main(). |
| python/packages/foundry_hosting/tests/test_responses.py | Adds end-to-end HTTP tests for hosting WorkflowAgent with tool approvals (streaming and non-streaming). |
| python/packages/foundry_hosting/agent_framework_foundry_hosting/_responses.py | Plumbs approval storage through input/output conversion so approval responses can be reconstructed. |
| python/packages/core/tests/workflow/test_workflow_status.py | New tests for the new Workflow.status property across success/failure/pending-request flows. |
| python/packages/core/tests/workflow/test_workflow_agent.py | Updates request-info/tool-approval expectations and adds tests ensuring raw tool-approval content forwards unchanged. |
| python/packages/core/tests/workflow/test_agent_executor.py | Adds regression tests for “double-emission” of approval payload and request-id matching. |
| python/packages/core/tests/core/test_skills.py | Minor parentheses cleanup in async awaits. |
| python/packages/core/agent_framework/_workflows/_workflow.py | Implements run-level status tracking (Workflow.status) and updates during execution. |
| python/packages/core/agent_framework/_workflows/_agent.py | Refactors WorkflowAgent continuation logic to depend on Workflow.status and adjusts request-info conversion. |
| python/packages/core/agent_framework/_workflows/_agent_executor.py | Adjusts approval request handling to avoid double-emitting approval payloads and passes explicit request_id. |
| python/packages/core/agent_framework/_skills.py | Minor formatting of tool descriptions. |
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Motivation and Context
Function approval was not handled correctly when the approval comes from an agent within a workflow that is used as an agent.
Addresses #5654
Description
function_approval_requestwill now pass through while other request events will be serialized tofunction_callcontents.Old data flow:
New data flow:
Contribution Checklist