You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Rebuild detection on ground truth: Claude Code hooks (v1.1.0)
After repeated both-ways failures (sleeps mid-task / won't sleep after),
the root problem was the approach: inferring agent state from transcript
formats and CPU/network thresholds is inherently fragile. Vigil now installs
a Claude Code hook (merged into ~/.claude/settings.json — one-time backup,
idempotent, refuses unparseable JSON, user's hooks untouched) so Claude
itself reports state instantly:
UserPromptSubmit/PreToolUse/PostToolUse -> active (with claude pid)
Notification (permission/idle prompt) -> waiting (human needed; may sleep)
Stop/SessionEnd -> idle
Detection tiers: hooks (primary, immediate) > transcript semantic (only for
sessions without markers) > debounced net/CPU heuristic. Found the main
"never sleeps" culprit on real hardware: an IDLE Claude Desktop window burns
~10% CPU compositing its Electron UI, permanently tripping the CPU threshold
- GUI apps are now judged by sustained network only. Claude Code CLI
processes are dropped from the heuristic when hooks are live.
Hardening from adversarial review: pid-less active markers trusted only
10 min; stale markers cross-checked against the transcript (lost-Stop guard:
turn ended after marker -> idle; mid-tool -> stays active, so a single long
tool survives); hook script lands the event before pid discovery so a slow
ps can never lose it.
Verified: settings merge diffed (all user keys/hooks preserved, idempotent
across relaunches); hook script per-event; detector states incl. dead-pid/
stale/waiting/lost-Stop/long-tool; modes off/keepAwake; live ground truth
(real markers from real sessions, active with live pid / idle after Stop).
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
0 commit comments