021ee34546
Closes #63529 Root cause: GatewayRunner._drain_active_agents only waited on _running_agents + cron in-flight counts. Desktop/API sessions are tracked solely inside APIServerAdapter (_inflight_agent_runs + _active_run_agents), so stop/restart logged active_at_start=0 and systemd SIGKILL'd mid-tool work. Fix: APIServerAdapter.active_agent_work_count() plus GatewayRunner._active_api_run_count() folded into the drain wait, status updates, timeout result, and shutdown logs — same pattern as _active_cron_job_count for #60432. Verification: pytest tests/gateway/test_api_server_active_work_drain.py tests/gateway/test_cron_active_work_drain.py -q → 19 passed