-
Notifications
You must be signed in to change notification settings - Fork 1k
[BREAKING] Python: Add factory pattern to GroupChat and Magentic #3224
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
[BREAKING] Python: Add factory pattern to GroupChat and Magentic #3224
Conversation
There was a problem hiding this 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 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 |
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