# Implementation Plan: Kill/Abort Running Workers (kill_abort_workers_20260306)

> **Reference:** [Spec](./spec.md) | [Architecture Guide](../../../docs/guide_architecture.md)

## Phase 1: Thread Tracking
Focus: Track active worker threads

- [x] Task 1.1: Initialize MMA Environment
- [x] Task 1.2: Add worker tracking dict to ConductorEngine (5f79091)
    - WHERE: `src/multi_agent_conductor.py` `ConductorEngine.__init__`
    - WHAT: Dict to track active workers
    - HOW:
      ```python
      self._active_workers: dict[str, threading.Thread] = {}
      self._abort_events: dict[str, threading.Event] = {}
      ```

## Phase 2: Abort Mechanism
Focus: Add abort signal to workers

- [x] Task 2.1: Create abort event per ticket (da011fb)
    - WHERE: `src/multi_agent_conductor.py` before spawning worker
    - WHAT: Create threading.Event for abort
    - HOW: `self._abort_events[ticket.id] = threading.Event()`

- [x] Task 2.2: Check abort in worker lifecycle (597e6b5)
    - WHERE: `src/multi_agent_conductor.py` `run_worker_lifecycle()`
    - WHAT: Check abort event between operations
    - HOW:
      ```python
      abort_event = engine._abort_events.get(ticket.id)
      if abort_event and abort_event.is_set():
       ticket.status = "killed"
       return
      ```

## Phase 3: Kill Button UI
Focus: Add kill button to GUI

- [x] Task 3.1: Add kill button per worker (d74f629)
    - WHAT: Button to kill specific worker
    - HOW:
      ```python
      for ticket_id, thread in engine._active_workers.items():
       if thread.is_alive():
        if imgui.button(f"Kill {ticket_id}"):
         engine.kill_worker(ticket_id)
      ```

- [x] Task 3.2: Implement kill_worker method (597e6b5)
    - WHERE: `src/multi_agent_conductor.py`
    - WHAT: Set abort event and wait for termination
    - HOW:
      ```python
      def kill_worker(self, ticket_id: str) -> None:
       if ticket_id in self._abort_events:
        self._abort_events[ticket_id].set()
       if ticket_id in self._active_workers:
        self._active_workers[ticket_id].join(timeout=2.0)
        del self._active_workers[ticket_id]
      ```

## Phase 4: Testing
- [ ] Task 4.1: Write unit tests
- [ ] Task 4.2: Conductor - Phase Verification
