Skip to content

[BREAKING] Python: Merge send_responses into run method#3720

Merged
moonbox3 merged 4 commits intomicrosoft:mainfrom
moonbox3:3687-implement
Feb 6, 2026
Merged

[BREAKING] Python: Merge send_responses into run method#3720
moonbox3 merged 4 commits intomicrosoft:mainfrom
moonbox3:3687-implement

Conversation

@moonbox3
Copy link
Contributor

@moonbox3 moonbox3 commented Feb 6, 2026

Motivation and Context

  • Removes send_responses() and send_responses_streaming() from the Workflow public API
  • Adds a responses parameter to workflow.run(), enabling run(responses=..., checkpoint_id=..., **kwargs) in a single call
  • Adopts ResponseStream pattern (matching agent/chat client layer) instead of leaking bare async generators
  • Adds lightweight type coercion in _send_responses_internal so raw JSON values (dicts, ints) are converted to expected types (dataclasses, floats) before validation

New items:

  • _run_core() is a single async generator; cleanup is handled declaratively via ResponseStream.cleanup_hooks
  • DevUI executor simplified from a two-step checkpoint-restore-then-send hack to a single workflow.run() call
  • All samples and tests updated to use run(responses=...) instead of the removed methods

Description

Contribution Checklist

  • The code builds clean without any errors or warnings
  • The PR follows the Contribution Guidelines
  • All unit tests pass, and I have added new tests where possible
  • Is this a breaking change? If yes, add "[BREAKING]" prefix to the title of the PR.

@moonbox3 moonbox3 self-assigned this Feb 6, 2026
Copilot AI review requested due to automatic review settings February 6, 2026 09:53
@moonbox3 moonbox3 added the python label Feb 6, 2026
@moonbox3 moonbox3 added workflows Related to Workflows in agent-framework breaking change Introduces changes that are not backward compatible and may require updates to dependent code. labels Feb 6, 2026
@moonbox3 moonbox3 moved this to In Review in Agent Framework Feb 6, 2026
@markwallace-microsoft
Copy link
Member

markwallace-microsoft commented Feb 6, 2026

Python Test Coverage

Python Test Coverage Report •
FileStmtsMissCoverMissing
packages/core/agent_framework/_workflows
   _agent.py3466581%59, 67–73, 107–108, 350–351, 357–358, 364, 366, 371, 454–455, 464, 471, 497, 530–532, 534, 536, 538, 543, 548, 595, 625, 642, 681–684, 690, 696, 700–701, 704–710, 714–715, 721, 782, 789, 795–796, 807, 839, 846, 867, 876, 880, 882–884, 891
   _typing_utils.py1463377%153, 177, 219–223, 304, 306–307, 316, 318, 325, 327, 347, 349, 351, 356–363, 366–367, 369–373, 375
   _workflow.py2622690%87, 265–267, 269–270, 288, 292, 320, 422, 597, 618, 644, 671, 673–674, 679–680, 686, 692, 697, 717–719, 732, 800
   _workflow_executor.py1823083%94, 444, 468, 470, 478–479, 484, 486, 491, 493, 546, 574–580, 584–586, 594, 599, 610, 620, 624, 630, 634, 644, 648
packages/orchestrations/agent_framework_orchestrations
   _magentic.py6179085%67–76, 81, 85–96, 261, 272, 276, 296, 357, 366, 368, 410, 427, 436–437, 439–441, 443, 454, 596, 598, 638, 686, 722–724, 726, 734–737, 741–744, 805–808, 899, 905, 911, 953, 991, 1023, 1040, 1051, 1108–1109, 1113–1115, 1139, 1163–1164, 1177, 1193, 1215, 1263–1264, 1302–1303, 1462, 1471, 1474, 1479, 1875, 1930, 1945, 1974
TOTAL16589203587% 

Python Unit Test Overview

Tests Skipped Failures Errors Time
3919 225 💤 0 ❌ 0 🔥 1m 6s ⏱️

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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() and send_responses_streaming() public methods from Workflow
  • Enhanced run() with a new responses parameter enabling run(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

@moonbox3 moonbox3 changed the title Python: Merge send_responses into run method [BREAKING] Python: Merge send_responses into run method Feb 6, 2026
@eavanvalkenburg eavanvalkenburg added this pull request to the merge queue Feb 6, 2026
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Feb 6, 2026
@moonbox3 moonbox3 added this pull request to the merge queue Feb 6, 2026
Merged via the queue into microsoft:main with commit a17f135 Feb 6, 2026
23 checks passed
@github-project-automation github-project-automation bot moved this from In Review to Done in Agent Framework Feb 6, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

breaking change Introduces changes that are not backward compatible and may require updates to dependent code. python workflows Related to Workflows in agent-framework

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

Python: Merge send_responses into run method

4 participants