Title: feat: squad watch health — show running watch instance status with background agent detection · Issue #808 · github/squad · GitHub
Open Graph Title: feat: squad watch health — show running watch instance status with background agent detection · Issue #808 · github/squad
X Title: feat: squad watch health — show running watch instance status with background agent detection · Issue #808 · github/squad
Description: Summary Add a squad watch health (or squad watch --health) command that shows the real-time health status of all running Squad Watch instances on the current machine. Today, diagnosing whether a watch is "stuck" vs "actively working" req...
Open Graph Description: Summary Add a squad watch health (or squad watch --health) command that shows the real-time health status of all running Squad Watch instances on the current machine. Today, diagnosing whether a wa...
X Description: Summary Add a squad watch health (or squad watch --health) command that shows the real-time health status of all running Squad Watch instances on the current machine. Today, diagnosing whether a wa...
Opengraph URL: https://github.com/github/squad/issues/808
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"feat: squad watch health — show running watch instance status with background agent detection","articleBody":"## Summary\n\nAdd a `squad watch health` (or `squad watch --health`) command that shows the real-time health status of all running Squad Watch instances on the current machine. Today, diagnosing whether a watch is \"stuck\" vs \"actively working\" requires manual process tree inspection — this command should automate that.\n\n## Background / Problem\n\nWhen `squad watch` runs, each round spawns a Copilot CLI session (via `agency.exe`) that can run background agents (sub-agent `pwsh.exe` shells). A round that appears \"stuck\" based on heartbeat age alone may actually be actively processing work through 30+ background agent shells.\n\n**Current diagnostic flow (manual, error-prone):**\n1. Read heartbeat JSON -> see round running for 100+ min -> assume stuck\n2. Actually need to: find the agency session PID -> check its child copilot.exe -> check copilot.exe's children (pwsh.exe background agents) -> check if any have CPU activity\n3. Also need to check the process log for last non-heartbeat activity timestamp\n4. Only truly stuck if: copilot.exe exited AND agency.exe still alive (zombie MCP servers), OR zero child processes have any CPU activity\n\n**Key insight:** A round with active background agents (pwsh.exe children with CPU > 0) is WORKING, not stuck. The heartbeat age alone is misleading.\n\n## Requirements\n\n### `squad watch health` output\n\nShow a table for each running watch instance on this machine:\n\n```\nSquad Watch Health\n==================\nRepo Round Status Duration Agents Last Activity\ntamresearch1 R2 Working 98m 35 2m ago (pwsh CPU active)\ntamresearch1-re R113 Idle 2m 0 2m ago (between rounds)\ncontent-empire -- Custom -- -- (no heartbeat)\n```\n\n### Health determination logic\n\nFor each watch instance:\n\n1. **Read heartbeat file** (`~/.squad/ralph-heartbeat-{repo}.json`) -> get PID, round, status, lastRun\n2. **Check if PID is alive** -> if dead, status = Dead\n3. **Find the agency session child process** (child of ralph-watch PID)\n4. **Find copilot.exe grandchild** of the agency process\n5. **Count active background agents** -- pwsh.exe children of copilot.exe with CPU > 0\n6. **Check process log** for last non-heartbeat line timestamp\n7. **Determine status:**\n - **Working** -- copilot.exe alive AND (background agents with CPU > 0 OR last log activity \u003c 5m ago)\n - **Slow** -- copilot.exe alive but no CPU activity for 10+ min AND no log activity for 10+ min\n - **Stuck** -- copilot.exe exited but agency.exe still alive (zombie MCP servers), OR PID dead, OR no activity for 30+ min\n - **Unknown** -- no heartbeat file (custom script, no monitoring)\n\n### Zombie MCP detection pattern\n\nThe specific zombie pattern discovered in production:\n- copilot.exe finishes LLM conversation (log shows `str_replace_editor_shutdown` + telemetry flush)\n- But agency.exe stays alive because MCP server child processes (voicemcp, aspire, configgen, enghub) keep heartbeating every 30s\n- The process log tail is 100% heartbeat lines with no real activity\n- **Detection:** Last non-heartbeat log line is 30+ min old while heartbeat lines are \u003c 1 min old\n- Filter heartbeat noise with: lines matching `heartbeat|gateway|Start processing|Sending HTTP|Received HTTP|End processing`\n\n### Data sources\n\n| Data | Location |\n|------|----------|\n| Heartbeat | `~/.squad/ralph-heartbeat-{repo}.json` |\n| Process log | `~/.agency/logs/session_*/process-*.log` (latest session dir) |\n| Watch log | `~/.squad/ralph-watch-{repo}.log` |\n| Process tree | Win: `Get-CimInstance Win32_Process`, Linux: `pstree`/`/proc` |\n| Scheduled tasks | Win: `Get-ScheduledTask -TaskPath \"\\Squad\\\"` |\n\n### CLI flags\n\n- `squad watch health` -- show all instances\n- `squad watch health --json` -- machine-readable output\n- `squad watch health --repo \u003cname>` -- filter to specific repo\n- `squad watch health --kill-stuck` -- kill stuck instances and restart via scheduled task\n\n### Real-world example\n\nFrom debugging on CPC-tamir-3H7BI (2026-04-04):\n- Ralph R2 appeared \"stuck\" at 98 min based on heartbeat age\n- copilot.exe was ALIVE with ~35 pwsh.exe background agent shells as children\n- LLM conversation finished at 10:33 UTC but background agents were still running\n- Heartbeat-only diagnosis would have incorrectly killed a working session\n- Proper diagnosis: check child process count + CPU activity = actively working\n\n## Acceptance Criteria\n\n- [ ] `squad watch health` shows status of all watch instances on the machine\n- [ ] Correctly distinguishes \"working with background agents\" from \"stuck with zombie MCPs\"\n- [ ] Shows background agent count and last real activity timestamp\n- [ ] `--json` flag for programmatic consumption\n- [ ] `--kill-stuck` flag to auto-remediate\n- [ ] Works on Windows (primary) and Linux (secondary)","author":{"url":"https://github.com/tamirdresher","@type":"Person","name":"tamirdresher"},"datePublished":"2026-04-04T11:55:08Z","url":"https://github.com/github/squad/issues/808"}
| react-profiling | 0 |
| react-import-map | react,react-dom,react-dom/client,react-dom/profiling,react-is,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@b8488ee2c322 |
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:f045a179-7399-b520-9fea-4d875cf1f360 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | 8D36:33D24F:1C2FBFB:241F004:6B0160B5 |
| html-safe-nonce | fb038356c0d10ab263e863a5804bdd8a87f5a21db2a5044cb26520f34c41c170 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI4RDM2OjMzRDI0RjoxQzJGQkZCOjI0MUYwMDQ6NkIwMTYwQjUiLCJ2aXNpdG9yX2lkIjoiMzU4OTE2OTA2ODU3MTE4OTQyOSIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | 04742917308a0ca0ad86688763f54c1487faac8e154d1126bc324ff7915a343d |
| hovercard-subject-tag | issue:4204720300 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/github/squad/808/issue_layout |
| twitter:image | https://opengraph.githubassets.com/d6a9751e501afa374fc11cb509b532b7d0b716aaa24e656ac3c6337ec54aa01f/github/squad/issues/808 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/d6a9751e501afa374fc11cb509b532b7d0b716aaa24e656ac3c6337ec54aa01f/github/squad/issues/808 |
| og:image:alt | Summary Add a squad watch health (or squad watch --health) command that shows the real-time health status of all running Squad Watch instances on the current machine. Today, diagnosing whether a wa... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | tamirdresher |
| hostname | github.com |
| expected-hostname | github.com |
| None | cc5dfdd32f62ebd3223cab3af3aa2b268d3605218237326a48a99d1efd89495c |
| turbo-cache-control | no-preview |
| go-import | github.com/github/squad git https://github.com/github/squad.git |
| octolytics-dimension-user_id | 9919 |
| octolytics-dimension-user_login | github |
| octolytics-dimension-repository_id | 1151205052 |
| octolytics-dimension-repository_nwo | github/squad |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 1151205052 |
| octolytics-dimension-repository_network_root_nwo | github/squad |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 8c77c9e8439031ad54c75a250694842892f693e1 |
| ui-target | canary-2 |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
Viewport: width=device-width