Stop a running coding agent and all its child processes.
(self, feature_id: int)
| 1305 | self._signal_agent_completed() |
| 1306 | |
| 1307 | def stop_feature(self, feature_id: int) -> tuple[bool, str]: |
| 1308 | """Stop a running coding agent and all its child processes.""" |
| 1309 | with self._lock: |
| 1310 | # Check if this feature is part of a batch |
| 1311 | primary_id = self._feature_to_primary.get(feature_id, feature_id) |
| 1312 | if primary_id not in self.running_coding_agents: |
| 1313 | return False, "Feature not running" |
| 1314 | |
| 1315 | abort = self.abort_events.get(primary_id) |
| 1316 | proc = self.running_coding_agents.get(primary_id) |
| 1317 | |
| 1318 | if abort: |
| 1319 | abort.set() |
| 1320 | if proc: |
| 1321 | result = kill_process_tree(proc, timeout=5.0) |
| 1322 | debug_log.log("STOP", f"Killed feature {feature_id} (primary {primary_id}) process tree", |
| 1323 | status=result.status, children_found=result.children_found, |
| 1324 | children_terminated=result.children_terminated, children_killed=result.children_killed) |
| 1325 | |
| 1326 | return True, f"Stopped feature {feature_id}" |
| 1327 | |
| 1328 | def stop_all(self) -> None: |
| 1329 | """Stop all running agents (coding and testing).""" |
no test coverage detected