Skip to content

refactor(backend): unify EnhancedMultiAgentOrchestrator into ConsolidatedOrchestrator (Phase 4) #5037

Closed

Description

@mrveiss

Context

Follow-up from #4048 (consolidation 5→4). The 4-file target was met, but under the hood we still have two separate orchestrator classes and two runtime singletons:

  1. `ConsolidatedOrchestrator` in `autobot-backend/orchestrator.py` — singleton via `get_orchestrator_sync()`
  2. `EnhancedMultiAgentOrchestrator` in `autobot-backend/enhanced_orchestration/init.py` — module-level singleton `enhanced_orchestrator`

Both are instantiated at startup. Production code creates instances of both:

  • `services/workflow_automation/manager.py:58-59` constructs both side-by-side
  • `services/advanced_workflow/step_generator.py` uses `EnhancedMultiAgentOrchestrator` via `get_orchestrator()`

Gaps

Gap 1 — Two classes, same role

`EnhancedMultiAgentOrchestrator` and `ConsolidatedOrchestrator` both plan and execute multi-agent workflows. The split is historical, not architectural. True consolidation means one class.

Gap 2 — 663-line `init.py` (code smell)

In #4048, `enhanced_orchestration/orchestrator.py` was inlined into `enhanced_orchestration/init.py` (663 lines, 2 top-level classes/functions, plus a module-level singleton). This preserves the import surface (`from enhanced_orchestration import enhanced_orchestrator`) but violates the convention that `init.py` should be a re-export layer, not the implementation.

Proposed fix

Option A (preferred, Phase 4 completion): Merge the useful methods from `EnhancedMultiAgentOrchestrator` into `ConsolidatedOrchestrator`. Delete `enhanced_orchestration/init.py`'s class content. Update `api/orchestration.py` and all callers to use `ConsolidatedOrchestrator` exclusively. Delete the `enhanced_orchestration` package if it becomes empty of logic (keep `types.py`, `success_criteria.py`, etc. if still referenced).

Option B (interim if A is too disruptive): Move `EnhancedMultiAgentOrchestrator` out of `init.py` into a named module (e.g., `enhanced_orchestration/multi_agent.py`). Update `init.py` to only re-export. Keeps the two-class status quo but fixes the code-smell.

Acceptance criteria

  • Either: exactly one orchestrator class (A), OR `enhanced_orchestration/init.py` is <100 lines of re-exports only (B)
  • All existing orchestration tests still pass (`pytest autobot-backend/tests/orchestration/`)
  • No stale references to deleted symbols anywhere under `autobot-backend/`

Related

Activity

  1. mrveiss commented on Apr 17, 2026

    @mrveiss
    OwnerAuthor

    ✅ Closed by PR #5053 (merged in 7b74d42) — subsumed by #5040.

    EnhancedMultiAgentOrchestrator merged into the single Orchestrator class (22 methods ported). The 663-line enhanced_orchestration/__init__.py trimmed to 58 lines of re-exports only. Duplicate _update_agent_performance deduplicated.

    Follow-up tracked in #5058: the merged Orchestrator still has three overlapping workflow execution paths internally — that's the next phase.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions