feat(conductor): Add pause/resume mechanism to ConductorEngine

This commit is contained in:
2026-03-07 16:36:04 -05:00
parent ce99c18cbd
commit 0c3a2061e7
2 changed files with 38 additions and 2 deletions

View File

@@ -90,6 +90,7 @@ class ConductorEngine:
self._workers_lock = threading.Lock()
self._active_workers: dict[str, threading.Thread] = {}
self._abort_events: dict[str, threading.Event] = {}
self._pause_event: threading.Event = threading.Event()
self._tier_usage_lock = threading.Lock()
def update_usage(self, tier: str, input_tokens: int, output_tokens: int) -> None:
@@ -98,6 +99,14 @@ class ConductorEngine:
self.tier_usage[tier]["input"] += input_tokens
self.tier_usage[tier]["output"] += output_tokens
def pause(self) -> None:
"""Pauses the pipeline execution."""
self._pause_event.set()
def resume(self) -> None:
"""Resumes the pipeline execution."""
self._pause_event.clear()
def kill_worker(self, ticket_id: str) -> None:
"""Sets the abort event for a worker and attempts to join its thread."""
if ticket_id in self._abort_events:
@@ -164,11 +173,14 @@ class ConductorEngine:
md_content: The full markdown context (history + files) for AI workers.
max_ticks: Optional limit on number of iterations (for testing).
"""
self._push_state(status="running", active_tier="Tier 2 (Tech Lead)")
import sys
tick_count = 0
while True:
if self._pause_event.is_set():
self._push_state(status="paused", active_tier="Paused")
time.sleep(0.5)
continue
self._push_state(status="running", active_tier="Tier 2 (Tech Lead)")
if max_ticks is not None and tick_count >= max_ticks:
break
tick_count += 1