-
Notifications
You must be signed in to change notification settings - Fork 1k
Python: WorkflowBuilder registry #2486
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
Python: WorkflowBuilder registry #2486
Conversation
python/packages/core/agent_framework/_workflows/_workflow_builder.py
Outdated
Show resolved
Hide resolved
python/packages/core/agent_framework/_workflows/_workflow_builder.py
Outdated
Show resolved
Hide resolved
python/packages/core/agent_framework/_workflows/_workflow_builder.py
Outdated
Show resolved
Hide resolved
|
Also, is this truly breaking? It should be additive, right? |
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 introduces a factory-based registration pattern for executors and agents in the WorkflowBuilder, enabling lazy initialization and isolated workflow instances. Key changes include new register_executor() and register_agent() methods, deprecation warnings for direct instance addition, and comprehensive sample updates demonstrating the new pattern.
- Factory-based registration via
register_executor()andregister_agent()for deferred instantiation - Backward compatibility maintained with deprecation warnings on
add_agent()and direct executor addition - All 25+ sample files migrated to use the factory pattern
- Comprehensive test coverage for new registration patterns
- New sample file (
step4_using_factories.py) demonstrating best practices
Reviewed changes
Copilot reviewed 33 out of 33 changed files in this pull request and generated 16 comments.
Show a summary per file
| File | Description |
|---|---|
_workflow_builder.py |
Implements executor/agent factory registration with deferred edge resolution |
_workflow.py |
Simplifies start executor handling to require Executor instance |
_validation.py |
Updates validation to accept Executor instance instead of union type |
_edge.py |
Allows Case and Default targets to be strings for deferred resolution |
test_workflow_builder.py |
Adds 13 new tests for factory registration patterns |
| Sample files (25+) | Migrated to factory pattern with agent/executor factory functions |
Motivation and Context
Closing #429
Description
Add support for providing factories to create executors and agents to the workflow builder to allow the workflow builder to create isolated workflow instances.
builder.register_executor().builder.register_agent().Contribution Checklist