Python: Add factory pattern to sequential orchestration builder#2710
Merged
TaoChenOSU merged 7 commits intomicrosoft:mainfrom Dec 10, 2025
Merged
Conversation
Member
Python Test Coverage Report •
Python Unit Test Overview
|
|||||||||||||||||||||||||||||||||||
TaoChenOSU
commented
Dec 9, 2025
moonbox3
reviewed
Dec 9, 2025
Contributor
There was a problem hiding this comment.
Pull request overview
This PR adds a factory pattern to the SequentialBuilder to enable proper state isolation between workflow instances. The feature allows users to register participant factories instead of participant instances, ensuring that each workflow built from the same builder gets fresh participant instances with independent state.
Key Changes:
- Added
register_participants()method to SequentialBuilder accepting factory functions - Updated SequentialBuilder to call factories during
build()to create fresh participant instances - Added comprehensive test coverage for factory pattern with various scenarios
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| python/samples/getting_started/workflows/orchestration/sequential_participant_factory.py | New sample demonstrating factory pattern usage with stateful accumulator showing state isolation between workflow instances |
| python/samples/getting_started/workflows/orchestration/sequential_custom_executors.py | Removed unused Never import and simplified code by removing type ignore comments |
| python/packages/core/tests/workflow/test_sequential.py | Added comprehensive tests for factory pattern including validation, checkpointing, builder reusability, and mixed participants |
| python/packages/core/agent_framework/_workflows/_typing_utils.py | Removed unused _coerce_to_type function and its associated imports |
| python/packages/core/agent_framework/_workflows/_sequential.py | Implemented factory pattern support with validation, added register_participants() method, updated build logic to call factories |
python/samples/getting_started/workflows/orchestration/sequential_participant_factory.py
Outdated
Show resolved
Hide resolved
moonbox3
reviewed
Dec 9, 2025
python/samples/getting_started/workflows/orchestration/sequential_participant_factory.py
Show resolved
Hide resolved
moonbox3
approved these changes
Dec 10, 2025
alliscode
reviewed
Dec 10, 2025
alliscode
approved these changes
Dec 10, 2025
arisng
pushed a commit
to arisng/agent-framework
that referenced
this pull request
Feb 2, 2026
…osoft#2710) * Add factory pattern to sequential orchestration builder * Use temp list to avoid override * Add sample and some other fixes * Fix comments * Small fix * Update readme
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
Follow up for #2486
Description
This PR adds factory to the sequential orchestration builder.
Contribution Checklist