From b693de2999a16cbcb31f3153b43b5ee281e92f38 Mon Sep 17 00:00:00 2001 From: Auto Date: Fri, 30 Jan 2026 09:07:40 +0200 Subject: [PATCH] fix: improve parallel orchestrator agent tracking clarity and cleanup - Add comment on running_coding_agents explaining why feature_id keying is safe (start_feature checks for duplicates before spawning), since the sister dict running_testing_agents required PID keying to avoid overwrites from concurrent same-feature testing - Clear running_testing_agents dict in stop_all() after killing processes so get_status() doesn't report stale agent counts while _on_agent_complete callbacks are still in flight Follow-up to PR #130 (runaway testing agent spawn fix). Co-Authored-By: Claude Opus 4.5 --- parallel_orchestrator.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/parallel_orchestrator.py b/parallel_orchestrator.py index 8c91db1..574cbd2 100644 --- a/parallel_orchestrator.py +++ b/parallel_orchestrator.py @@ -169,6 +169,7 @@ class ParallelOrchestrator: # Thread-safe state self._lock = threading.Lock() # Coding agents: feature_id -> process + # Safe to key by feature_id because start_feature() checks for duplicates before spawning self.running_coding_agents: dict[int, subprocess.Popen] = {} # Testing agents: pid -> (feature_id, process) # Keyed by PID (not feature_id) because multiple agents can test the same feature @@ -906,6 +907,11 @@ class ParallelOrchestrator: status=result.status, children_found=result.children_found, children_terminated=result.children_terminated, children_killed=result.children_killed) + # Clear dict so get_status() doesn't report stale agents while + # _on_agent_complete callbacks are still in flight. + with self._lock: + self.running_testing_agents.clear() + async def run_loop(self): """Main orchestration loop.""" self.is_running = True