Skip to content

refactor(backend): one conductor — single Orchestrator class + 7 renames (#5040) - #5053

Merged
mrveiss merged 6 commits into
Dev_new_guifrom
issue-5040
Apr 17, 2026
Merged

mrveiss merged 6 commits into
Dev_new_guifrom
issue-5040

Conversation

@mrveiss

@mrveiss mrveiss commented Apr 17, 2026

Copy link
Copy Markdown
Owner

Closes #5040, #5037, #5038, #5039
Subsumes PR #5027 (#4048) — close that PR in favor of this one.

The Rule

In an orchestra, there is only one conductor.

Before this PR, the codebase had 8 classes named `*Orchestrator`. After this PR, there is one `Orchestrator` class (the multi-agent conductor) plus 6 appropriately-named specialized coordinators/dispatchers/runners. Zero backward-compat aliases. Zero shim files.

Commits (reviewable independently)

  1. `8493bb7f8` — merge `EnhancedMultiAgentOrchestrator` into `ConsolidatedOrchestrator` (22 unique methods ported; duplicate `_update_agent_performance` deduplicated — one renamed to `_update_task_agent_performance` since the two versions operate on different data structures)
  2. `00919e750` — rename `ConsolidatedOrchestrator` → `Orchestrator` (the single conductor)
  3. `27d704020` — rename 6 misnamed specialized classes (table below), with old `*_orchestrator.py` files kept as shims (removed in commit 5)
  4. `f3d32b1c1` — align `ResourceFactory.get_orchestrator` (closes discovery(backend): rename ResourceFactory.get_enhanced_orchestrator → get_orchestrator (stale terminology) #5038) + remove `as Orchestrator` alias imports from 12 test files (closes discovery(backend): 12 test files use 'ConsolidatedOrchestrator as Orchestrator' alias #5039)
  5. `16438075a` — delete all shim files and alias imports (`services/orchestration/subagent_orchestrator.py`, `services/slm/deployment_orchestrator.py`, `services/advanced_workflow/orchestrator.py`), rename `enhanced_orchestrator` module variable in `api/orchestration.py` → `orchestrator`, rename `tests/orchestration/test_subagent_orchestrator_reflection.py` → `test_subagent_dispatcher_reflection.py`
  6. `df28968ba` — clean up stale `AgentOrchestrator` string reference in `agent_config.py`

Class rename table

Before After File
`ConsolidatedOrchestrator` + `EnhancedMultiAgentOrchestrator` `Orchestrator` (THE conductor) `autobot-backend/orchestrator.py`
`SLMDeploymentOrchestrator` `SLMDeploymentBridge` `services/slm/deployment_bridge.py`
`DeploymentOrchestrator` `DeploymentCoordinator` `services/slm/deployment_coordinator.py`
`SubagentOrchestrator` `SubagentDispatcher` `services/orchestration/subagent_dispatcher.py`
`AutonomousLoopOrchestrator` `AutonomousLoopRunner` `services/knowledge/autonomous_loop.py`
`AdvancedWorkflowOrchestrator` `WorkflowCoordinator` `services/advanced_workflow/coordinator.py`
`AgentOrchestrator` `DistributedAgentCoordinator` `agents/agent_orchestration/coordinator.py`

Non-negotiables verified

✅ Zero functionality loss — all 22 unique methods from `EnhancedMultiAgentOrchestrator` ported to `Orchestrator`; all 6 specialized classes preserved behavior (rename-only).
✅ Function uniqueness — `grep -rn "ConsolidatedOrchestrator|EnhancedMultiAgentOrchestrator|SLMDeploymentOrchestrator|AutonomousLoopOrchestrator|AdvancedWorkflowOrchestrator|\bAgentOrchestrator\b|SubagentOrchestrator|\bDeploymentOrchestrator\b" autobot-backend/ --include="*.py"` returns only historical commit-message references in docstrings.
✅ Function reusability — duplicate `_update_agent_performance` resolved; shared logic lives in one place.
✅ *`grep -rn "^class.Orchestrator\b" autobot-backend/` shows exactly: `orchestrator.py:215:class Orchestrator:`

Test status

  • ✅ 34/34 orchestration tests pass (`autobot-backend/tests/orchestration/`)
  • ✅ 349 tests pass in full suite
  • Pre-existing failures (unrelated to this PR): 2 in `a2a_security_test.py` (trace event assertions), 4 in `test_experiment_tracker` (Redis-unavailable), 3 collection errors (Pydantic deprecation). All confirmed present on baseline.

Breaking change

Any external consumer importing the old class names must update imports. No backward-compat shims provided — the conductor metaphor requires a clean surface.

🤖 Generated with Claude Code

mrveiss and others added 6 commits April 17, 2026 15:49
…solidatedOrchestrator (#5040)

MERGE PLAN SUMMARY:
- EnhancedMultiAgentOrchestrator had 23 methods; 22 unique, 1 name-collision
- Unique methods ported into ConsolidatedOrchestrator:
  create_workflow_plan, execute_workflow, _execute_single_agent_task,
  get_agent_recommendations, get_performance_report, _calculate_capability_coverage,
  _build_planning_prompt, _parse_planning_response, _evaluate_workflow_criteria,
  _handle_workflow_execution_success, _handle_workflow_execution_failure,
  _handle_task_timeout, _handle_task_exception, _coordinate_collaboration,
  _broadcast_to_agents, _update_workflow_performance_metrics, _publish_workflow_event,
  _get_agent_instance, _get_ma_strategy_handler, _ensure_ma_redis
- Duplicate: _update_agent_performance — both classes had it but with different
  data structures (AgentProfile vs AgentPerformance). Ported version renamed to
  _update_task_agent_performance to preserve both behaviours unambiguously.
- create_and_execute_workflow() convenience fn moved to orchestrator.py
- enhanced_orchestration/__init__.py trimmed to re-exports only (<60 lines)
- api/orchestration.py updated to use get_orchestrator_sync() instead of the
  removed enhanced_orchestrator module-level singleton
- ResourceFactory.get_enhanced_orchestrator → get_orchestrator (with compat alias)
  cache key "enhanced_orchestrator" → "orchestrator" in get_all_cached_resources
- All 34 orchestration tests pass

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…r (single conductor, #5040)

- orchestrator.py: class renamed Orchestrator; ConsolidatedOrchestrator kept as
  backward-compat alias (= Orchestrator) so old imports still resolve
- get_orchestrator_sync() return type annotation updated
- __all__ updated: Orchestrator is primary export, ConsolidatedOrchestrator is compat alias
- 12 test/e2e files updated: `from orchestrator import ConsolidatedOrchestrator as Orchestrator`
  → `from orchestrator import Orchestrator` (alias no longer needed, #5039)
- dependencies.py: 4 occurrences updated
- initialization/lifespan.py: docstring references updated
- services/workflow_automation/manager.py: import updated
- services/advanced_workflow/step_generator.py: type annotation updated
- api/api_endpoint_migrations_test.py: test assertion updated for renamed class
- All 34 orchestration tests pass

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…, subagent, loop, workflow, agent) (#5040)

1. SLMDeploymentOrchestrator → SLMDeploymentBridge
   File: deployment_orchestrator.py → deployment_bridge.py (old file is compat shim)
   Call-sites: api/slm/deployments.py, deployments_api_test.py updated to import
   from deployment_bridge; initialization/lifespan.py updated

2. DeploymentOrchestrator → DeploymentCoordinator
   In deployment_bridge.py; old name re-exported via compat alias in shim

3. SubagentOrchestrator → SubagentDispatcher
   File: subagent_orchestrator.py → subagent_dispatcher.py (old file is compat shim)
   get_subagent_orchestrator alias kept; test patching updated to target dispatcher

4. AutonomousLoopOrchestrator → AutonomousLoopRunner
   Same file; get_loop_orchestrator → get_loop_runner; callers in knowledge_rag.py
   and test_autonomous_loop.py updated via import alias

5. AdvancedWorkflowOrchestrator → WorkflowCoordinator
   File: orchestrator.py → coordinator.py (old file is compat shim)
   routes.py, __init__.py updated to import from coordinator directly

6. AgentOrchestrator → DistributedAgentCoordinator
   Same file (agents/agent_orchestration/coordinator.py); get_agent_orchestrator
   alias kept in __init__.py for a2a/task_executor.py and other callers

All backward-compat shims ensure existing imports resolve without change.
All 34 orchestration tests pass.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…trator (#5040, closes #5038, #5039)

#5038: ResourceFactory.get_enhanced_orchestrator renamed to get_orchestrator
  - New primary method: ResourceFactory.get_orchestrator()
  - Backward-compat alias: get_enhanced_orchestrator() → calls get_orchestrator()
  - Cache key in get_all_cached_resources: "enhanced_orchestrator" → "orchestrator"
  - Module-level convenience get_orchestrator() updated to call get_orchestrator()
  These changes were applied in the Part A merge commit; this commit adds the
  MERGE_PLAN.md documentation artifact.

#5039: Remove `from orchestrator import ConsolidatedOrchestrator as Orchestrator`
  aliases in 12 test files — now `from orchestrator import Orchestrator` directly.
  Applied in Part B rename commit.

Full merge plan saved in MERGE_PLAN.md at worktree root.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…5040)

- Delete 3 shim files: subagent_orchestrator.py, deployment_orchestrator.py, advanced_workflow/orchestrator.py
- Remove alias imports in api/slm/deployments.py and deployments_api_test.py (DeploymentCoordinator/SLMDeploymentBridge used directly)
- Rename module-level variable enhanced_orchestrator → orchestrator in api/orchestration.py (15 occurrences)
- Remove ConsolidatedOrchestrator alias and __all__ entry from orchestrator.py
- Remove AgentOrchestrator/get_agent_orchestrator aliases from agents/agent_orchestration/__init__.py
- Remove AdvancedWorkflowOrchestrator alias from services/advanced_workflow/__init__.py
- Remove get_enhanced_orchestrator BC method from utils/resource_factory.py
- Update a2a/task_executor.py to import get_distributed_agent_coordinator directly
- Update a2a/a2a_test.py mock stubs to use get_distributed_agent_coordinator
- Rename test file to test_subagent_dispatcher_reflection.py; rename TestGetSubagentOrchestrator → TestGetSubagentDispatcher
- Fix stale AgentOrchestrator docstrings in a2a/task_executor.py and a2a/tracing.py
…t_config (#5040)

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant