Python: Refactor workflow as agent pending request handling#6259
Merged
TaoChenOSU merged 16 commits intoJun 5, 2026
Merged
Conversation
Contributor
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. |
Contributor
moonbox3
reviewed
Jun 2, 2026
moonbox3
reviewed
Jun 3, 2026
moonbox3
approved these changes
Jun 4, 2026
alliscode
reviewed
Jun 5, 2026
alliscode
approved these changes
Jun 5, 2026
alliscode
approved these changes
Jun 5, 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 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