---
created: "2026-03-28T16:40:00.000Z"
title: Fix list-psyches GC race condition with BUSY PID state
area: tooling
files:
  - owl.sh
  - live.sh
---

## Problem

When a Psyche processes a message, its poll process exits and the Agent re-polls with a new PID. There's a window between poll cycles where the old PID is dead. If `list-psyches` (or `list`) runs during that window, it sees a dead PID, declares it stale, and garbage-collects the perch — even though the Agent is alive and about to re-register.

Reproduced by todlando: Psyche replied to commune, he ran list-psyches, it cleaned the perch ("CLEANED:todlando-psyche (pid 53050 dead)"), but Psyche was alive — just between poll cycles.

## Solution

Introduce a "BUSY" PID state:
1. When _poll_once receives a message (or pulse), before exiting write `"pid":"BUSY"` to info.json
2. GC in list/list-psyches sees `"pid":"BUSY"` → skip cleanup, report as active/busy
3. GC sees numeric PID that's dead → stale, eligible for cleanup
4. When Agent re-polls, overwrites `"pid":"BUSY"` with new numeric PID as usual

Small change: PID write before poll exit + check in GC logic.

Source: todlando bug report via owl message (2026-03-28)
