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 <noreply@anthropic.com>
This commit is contained in:
Auto
2026-01-30 09:07:40 +02:00
parent 21fe28f51d
commit b693de2999

View File

@@ -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