-
-
Notifications
You must be signed in to change notification settings - Fork 1
Open
Description
Problem
`EnhancedOrchestrator()` is instantiated independently in 5+ locations, each creating its own agent registry, knowledge base, and LLM interface. There is no shared singleton or dependency injection pattern.
Evidence
grep -rn "EnhancedOrchestrator()" autobot-backend/ --include="*.py" | grep -v test | grep -v e2eInstances created in:
- `initialization/lifespan.py:856` — scheduler executor wiring (PR fix(orchestration): wire WorkflowExecutor into scheduler startup (#2166) #2201)
- `services/advanced_workflow/orchestrator.py:42` — AdvancedWorkflowOrchestrator
- `services/advanced_workflow/step_generator.py:43` — StepGenerator
- `services/workflow_automation/manager.py:54` — WorkflowAutomationManager
- `utils/resource_factory.py:99` — ResourceFactory (attempts to cache in app state)
Impact
Medium — Each instance has its own:
- Agent registry: Agent health/availability not shared — one instance marks an agent degraded, others don't see it
- Knowledge base: Separate connections, no shared cache
- LLM interface: Separate rate limit tracking
The scheduler's orchestrator (from #2166 fix) is particularly isolated — it doesn't share agent health state with the workflow automation manager's orchestrator.
Expected Fix
Use `resource_factory.py`'s caching pattern everywhere, or introduce a proper singleton:
# Option A: Use resource_factory everywhere
from utils.resource_factory import get_enhanced_orchestrator
orchestrator = get_enhanced_orchestrator()
# Option B: Module-level singleton
# enhanced_orchestrator.py
_instance = None
def get_instance():
global _instance
if _instance is None:
_instance = EnhancedOrchestrator()
return _instanceFiles
All files listed above that call `EnhancedOrchestrator()`.
Discovered During
Implementation of #2166 (scheduler wiring added yet another instance).
Reactions are currently unavailable