[BREAKING] Python: Merge send_responses into run method#3720
Merged
moonbox3 merged 4 commits intomicrosoft:mainfrom Feb 6, 2026
Merged
[BREAKING] Python: Merge send_responses into run method#3720moonbox3 merged 4 commits intomicrosoft:mainfrom
moonbox3 merged 4 commits intomicrosoft:mainfrom
Conversation
Member
Contributor
There was a problem hiding this comment.
Pull request overview
This PR consolidates the workflow response handling API by merging send_responses() and send_responses_streaming() into the unified run() method. The change simplifies the API surface and enables more powerful patterns like single-call checkpoint restoration with response delivery. The implementation adopts the ResponseStream pattern (matching the agent/chat client layer) and adds lightweight type coercion to handle raw JSON values from external sources like the DevUI.
Changes:
- Removed
send_responses()andsend_responses_streaming()public methods fromWorkflow - Enhanced
run()with a newresponsesparameter enablingrun(responses=..., checkpoint_id=..., stream=True)patterns - Added
try_coerce_to_type()utility for automatic type conversion (int→float, dict→dataclass, dict→Pydantic) - Refactored DevUI executor to use single-call
workflow.run()instead of two-step checkpoint-restore-then-send - Updated all samples and tests across the codebase to use the new API
Reviewed changes
Copilot reviewed 38 out of 38 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| python/packages/core/agent_framework/_workflows/_workflow.py | Core implementation: unified run() method with responses parameter, ResponseStream integration, and cleanup via hooks |
| python/packages/core/agent_framework/_workflows/_typing_utils.py | New try_coerce_to_type() function for automatic type coercion in responses |
| python/packages/core/agent_framework/_workflows/_agent.py | Updated WorkflowAgent to use run(responses=...) instead of removed methods |
| python/packages/core/agent_framework/_workflows/_workflow_executor.py | Updated sub-workflow executor to use new API |
| python/packages/orchestrations/agent_framework_orchestrations/_magentic.py | Updated docstring examples to reference new API |
| python/packages/declarative/agent_framework_declarative/_workflows/_executors_agents.py | Updated comments to reference new API |
| python/packages/devui/agent_framework_devui/_executor.py | Simplified from two-step to single-call pattern using run(checkpoint_id, responses, stream=True) |
| python/samples/getting_started/workflows/tool-approval/*.py | Updated to use run(stream=True, responses=...) pattern |
| python/samples/getting_started/workflows/human-in-the-loop/*.py | Updated to use new response-sending API |
| python/samples/getting_started/workflows/orchestration/magentic_human_plan_review.py | New sample demonstrating Magentic with human plan review using new API |
| python/samples/getting_started/workflows/declarative//.py | Updated to use new API |
| python/samples/getting_started/workflows/checkpoint/*.py | Updated checkpoint samples to use new API |
| python/samples/getting_started/workflows/composition/*.py | Updated composition samples to use new API |
| python/samples/getting_started/workflows/agents/*.py | Updated agent samples to use new API |
| python/samples/getting_started/orchestrations/*.py | Updated orchestration samples to use new API |
| python/samples/semantic-kernel-migration/orchestrations/handoff.py | Updated to use new API |
| python/samples/autogen-migration/orchestrations/03_swarm.py | Updated to use new API |
| python/packages/core/tests/workflow/test_workflow.py | Updated tests and error message expectations to match new API |
| python/packages/core/tests/workflow/test_sub_workflow.py | Updated sub-workflow tests to use new API |
| python/packages/core/tests/workflow/test_request_info_and_response.py | Updated request/response tests to use new API |
| python/packages/core/tests/workflow/test_agent_executor_tool_calls.py | Updated tool approval tests to use new API |
| python/packages/orchestrations/tests/test_magentic.py | Updated Magentic tests to use new API |
| python/packages/orchestrations/tests/test_handoff.py | Updated handoff tests to use new API |
| python/packages/orchestrations/tests/test_group_chat.py | Updated group chat tests to use new API |
...samples/getting_started/workflows/checkpoint/handoff_with_tool_approval_checkpoint_resume.py
Show resolved
Hide resolved
eavanvalkenburg
approved these changes
Feb 6, 2026
markwallace-microsoft
approved these changes
Feb 6, 2026
TaoChenOSU
approved these changes
Feb 6, 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
send_responses()andsend_responses_streaming()from theWorkflowpublic APIresponsesparameter toworkflow.run(), enablingrun(responses=..., checkpoint_id=..., **kwargs)in a single callResponseStreampattern (matching agent/chat client layer) instead of leaking bare async generators_send_responses_internalso raw JSON values (dicts, ints) are converted to expected types (dataclasses, floats) before validationNew items:
_run_core()is a single async generator; cleanup is handled declaratively viaResponseStream.cleanup_hooksworkflow.run()callrun(responses=...)instead of the removed methodsDescription
Contribution Checklist