Skip to content

Conversation

@TaoChenOSU
Copy link
Contributor

@TaoChenOSU TaoChenOSU commented Nov 26, 2025

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.

  1. To register an executor factory, use builder.register_executor().
  2. To register an agent factory, use builder.register_agent().
  3. Full backward compatibility with warnings to users that they should use the factory pattern.
  4. Update samples.

Contribution Checklist

  • The code builds clean without any errors or warnings
  • The PR follows the Contribution Guidelines
  • All unit tests pass, and I have added new tests where possible
  • Is this a breaking change? If yes, add "[BREAKING]" prefix to the title of the PR.

@TaoChenOSU TaoChenOSU self-assigned this Nov 26, 2025
@TaoChenOSU TaoChenOSU added the workflows Related to Workflows in agent-framework label Nov 26, 2025
@TaoChenOSU TaoChenOSU moved this to In Progress in Agent Framework Nov 26, 2025
@github-actions github-actions bot changed the title WorkflowBuilder registry Python: WorkflowBuilder registry Nov 26, 2025
@TaoChenOSU TaoChenOSU changed the title Python: WorkflowBuilder registry [BREAKING] Python: WorkflowBuilder registry Nov 26, 2025
@moonbox3
Copy link
Contributor

Also, is this truly breaking? It should be additive, right?

@markwallace-microsoft
Copy link
Member

markwallace-microsoft commented Dec 3, 2025

Python Test Coverage

Python Test Coverage Report •
FileStmtsMissCoverMissing
packages/core/agent_framework
   observability.py60910183%238, 264–266, 268, 270–274, 282–283, 288–289, 294–299, 322–324, 326–327, 333, 417, 427, 449, 455, 474–476, 484–486, 508–510, 520–522, 655, 657, 744–748, 751–755, 764–767, 777–780, 782, 1049, 1127–1129, 1199–1201, 1359, 1367, 1371, 1375, 1381, 1383, 1385, 1393, 1403, 1431–1432, 1445–1448, 1467–1469, 1471–1474, 1476–1477, 1481, 1484, 1542, 1558, 1562, 1696, 1698
packages/core/agent_framework/_workflows
   _edge.py2182688%36, 58–59, 61, 413–414, 419, 423–428, 430–432, 542, 656, 663–665, 712, 740, 766, 820, 834
   _validation.py145695%85, 132, 153, 247, 328, 331
   _workflow.py2491892%94, 264–266, 268–269, 287, 311, 313, 410, 659, 693, 698, 701, 720–722, 787
   _workflow_builder.py2863886%259, 596, 694, 700–701, 798–799, 805, 808, 810, 812, 819, 822–826, 828, 892, 959, 969, 1028–1029, 1164, 1178–1185, 1187, 1190, 1192–1194, 1202
TOTAL16180253884% 

Python Unit Test Overview

Tests Skipped Failures Errors Time
2312 130 💤 0 ❌ 0 🔥 58.062s ⏱️

@TaoChenOSU TaoChenOSU changed the title [BREAKING] Python: WorkflowBuilder registry Python: WorkflowBuilder registry Dec 3, 2025
@TaoChenOSU TaoChenOSU marked this pull request as ready for review December 3, 2025 22:47
Copilot AI review requested due to automatic review settings December 3, 2025 22:47
Copy link
Contributor

Copilot AI left a 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() and register_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

@moonbox3 moonbox3 enabled auto-merge December 5, 2025 05:25
@moonbox3 moonbox3 added this pull request to the merge queue Dec 5, 2025
Merged via the queue into microsoft:main with commit f2ed5b5 Dec 5, 2025
23 checks passed
@github-project-automation github-project-automation bot moved this from In Progress to Done in Agent Framework Dec 5, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

python workflows Related to Workflows in agent-framework

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

5 participants