[BREAKING] Python: Add factory pattern to GroupChat and Magentic#3224
Merged
TaoChenOSU merged 12 commits intomicrosoft:mainfrom Jan 28, 2026
Merged
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR adds factory pattern support to GroupChat and Magentic workflow builders, enabling reusable builder instances for creating multiple workflows with fresh agent instances. The PR also renames with_standard_manager to with_manager to better support both standard and custom manager implementations.
Changes:
- Added
register_participants()and factory support for participant creation in GroupChatBuilder and MagenticBuilder - Added
manager_factoryandagent_factoryoptions to MagenticBuilder'swith_manager()method - Added
orchestrator_factoryoption to GroupChatBuilder'swith_orchestrator()method - Renamed
with_standard_manager()towith_manager()across all samples and tests - Consolidated orchestrator configuration methods in GroupChatBuilder into a single
with_orchestrator()method
Reviewed changes
Copilot reviewed 23 out of 23 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| python/packages/core/agent_framework/_workflows/_magentic.py | Added participant and manager factory support to MagenticBuilder; renamed with_standard_manager to with_manager |
| python/packages/core/agent_framework/_workflows/_group_chat.py | Added participant and orchestrator factory support; consolidated with_agent_orchestrator and with_select_speaker_func into with_orchestrator |
| python/packages/core/agent_framework/_workflows/_handoff.py | Renamed participant_factories() to register_participants() for API consistency |
| python/packages/core/agent_framework/_workflows/_sequential.py | Updated error messages for consistency |
| python/packages/core/agent_framework/_workflows/_concurrent.py | Updated error messages for consistency |
| python/packages/core/tests/workflow/test_magentic.py | Added comprehensive factory tests and updated all method calls |
| python/packages/core/tests/workflow/test_group_chat.py | Added comprehensive factory tests and updated all method calls |
| python/packages/core/tests/workflow/test_handoff.py | Updated method calls to use register_participants() |
| python/packages/core/tests/workflow/test_workflow_kwargs.py | Updated method calls to new API |
| python/samples/* | Updated all sample code to use the new API |
Member
Contributor
Author
moonbox3
reviewed
Jan 15, 2026
moonbox3
approved these changes
Jan 15, 2026
python/samples/getting_started/workflows/orchestration/group_chat_philosophical_debate.py
Show resolved
Hide resolved
Member
eavanvalkenburg
left a comment
There was a problem hiding this comment.
just one unresolved comment left
Contributor
Author
Responded in the original comment |
eavanvalkenburg
approved these changes
Jan 28, 2026
Member
eavanvalkenburg
left a comment
There was a problem hiding this comment.
I would still prefer a slightly different approach, but I'll leave that up to your judgement.
eavanvalkenburg
approved these changes
Jan 28, 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
This completes #429
Description
with_standard_managertowith_managersince the API supports non-standard magentic manager implementations.participant_factoriesAPI toregister_participantto align with the rest of the orchestrations.Contribution Checklist