fix-dead-agents

Fix: dead agents hold worktree ownership for hours, blocking spawns (reaper gap)

Metadata

Statusopen ‖ paused
Created2026-07-26T06:36:46.052749585+00:00
Started2026-07-26T07:17:30.941002931+00:00
Completed2026-07-26T07:17:53.544327205+00:00
Tagsbug, dispatcher, worktree
Tokens0 in / 0 out

Description

Objective

Dead agents (process gone, status dead) still "own" their isolated worktree in the registry for hours, so any new spawn for that task fails with "isolated worktree X is owned by live attempt agent-Y (status Working); no process launched" — which then trips the spawn circuit breaker. Observed: agent-766/769 (fix-decouple-dispatch), agent-758 (fix-evaluation-satellite), agent-728 (repair-missing-agency-reasoning) dead 3-9h yet still blocking. wg agents kill --force just says "already dead — will be reconciled" but the worktree lock is never released.

Work

  • The reaper must release worktree ownership promptly when an agent process is dead (well within reaper_grace_seconds), not leave it "live."
  • A dead owner must not block a new spawn; spawn should be able to reclaim/recreate the worktree when the owning attempt is dead.
  • wg agents kill --force on an already-dead agent should release its worktree lock immediately.

Validation

  • Killing an agent frees its worktree within reaper_grace_seconds; a retry/spawn for that task succeeds without "worktree owned by live attempt."
  • A dead owner never blocks a new spawn.
  • wg agents kill --force on a dead agent releases the worktree lock.

Reference

This session: dead agents 766/769/758/728 blocked spawns for hours; required reaper wait + retry + breaker surgery.

Depends on

Required by

Log