[BREAKING] Python: Refactor workflow events to unified discriminated union pattern #3690
Merged
moonbox3 merged 15 commits intomicrosoft:mainfrom Feb 6, 2026
Merged
[BREAKING] Python: Refactor workflow events to unified discriminated union pattern #3690moonbox3 merged 15 commits intomicrosoft:mainfrom
moonbox3 merged 15 commits intomicrosoft:mainfrom
Conversation
Member
Contributor
There was a problem hiding this comment.
Pull request overview
This PR refactors Python workflow events from individual event subclasses (like ExecutorCompletedEvent, WorkflowOutputEvent, RequestInfoEvent) to a unified discriminated union pattern using a single generic WorkflowEvent[DataT] class with a type literal discriminator. This aligns with PR #3649 and resolves issues #3528 and #3547.
Changes:
- Replaced event subclasses with
WorkflowEvent[DataT]generic type - Changed event type checking from
isinstance(event, WorkflowOutputEvent)toevent.type == "output" - Updated all samples, tests, and documentation to use the new pattern
- Removed exported event subclasses from public API
Reviewed changes
Copilot reviewed 117 out of 118 changed files in this pull request and generated 15 comments.
Show a summary per file
| File | Description |
|---|---|
python/samples/**/*.py |
Updated 50+ sample files to use event.type == pattern instead of isinstance() |
python/packages/core/tests/**/*.py |
Updated 20+ test files with new event checking pattern |
python/packages/orchestrations/**/*.py |
Updated orchestration builders and tests |
python/packages/devui/**/*.py |
Updated DevUI mapper to use event.type discriminator |
python/packages/core/agent_framework/_workflows/*.py |
Core workflow implementation updates |
python/samples/getting_started/workflows/agents/azure_chat_agents_tool_calls_with_feedback.py
Show resolved
Hide resolved
python/samples/autogen-migration/orchestrations/01_round_robin_group_chat.py
Outdated
Show resolved
Hide resolved
python/samples/semantic-kernel-migration/orchestrations/concurrent_basic.py
Show resolved
Hide resolved
python/samples/getting_started/workflows/parallelism/fan_out_fan_in_edges.py
Show resolved
Hide resolved
python/samples/getting_started/workflows/declarative/marketing/main.py
Outdated
Show resolved
Hide resolved
python/samples/getting_started/workflows/declarative/deep_research/main.py
Outdated
Show resolved
Hide resolved
python/samples/getting_started/workflows/control-flow/sequential_streaming.py
Outdated
Show resolved
Hide resolved
python/samples/getting_started/workflows/agents/azure_chat_agents_tool_calls_with_feedback.py
Outdated
Show resolved
Hide resolved
python/samples/getting_started/orchestrations/group_chat_simple_selector.py
Outdated
Show resolved
Hide resolved
4 tasks
dmytrostruk
approved these changes
Feb 6, 2026
python/samples/getting_started/orchestrations/magentic_human_plan_review copy.py
Outdated
Show resolved
Hide resolved
eavanvalkenburg
approved these changes
Feb 6, 2026
Contributor
Author
|
@TaoChenOSU, I need these changes in for some other work I am doing - so I don't get stuck fixing conflicts for a day again. Please note anything and we can fast follow in another PR. Thanks. |
eavanvalkenburg
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
ExecutorCompletedEvent,WorkflowOutputEvent,RequestInfoEvent, etc.) with a single genericWorkflowEvent[DataT]class using atypeliteral discriminatorevent.type == "output"pattern instead ofisinstance(event, WorkflowOutputEvent)checksAgentRunEvent/AgentRunUpdateEventExecutorCompletedEvent,ExecutorFailedEvent,ExecutorInvokedEvent,RequestInfoEvent,SuperStepCompletedEvent,SuperStepStartedEvent,WorkflowFailedEvent,WorkflowLifecycleEvent,WorkflowOutputEvent,WorkflowStartedEvent,WorkflowStatusEventevent.type == "..."instead ofisinstance()Migration
Description
Contribution Checklist