Files
cleveragents-core/.opencode
freemo 79403188f6 build(agents): add stale supervisor cleanup at startup to prevent duplicates
When the product-builder is interrupted mid-run (Ctrl+C, crash, timeout),
supervisor sessions launched via prompt_async survive independently on the
OpenCode server. Restarting the product-builder without cleanup creates
duplicate supervisors — 22 agents competing for the same work, causing
duplicate PR reviews, conflicting git pushes, and wasted resources.

Added Phase C.0 (runs before planning or launching) that:
1. Queries GET /session for all server sessions
2. Filters for sessions with titles starting with "[CA-AUTO] supervisor:"
3. Aborts any that are still active via POST /session/:id/abort
4. Deletes the stale sessions via DELETE /session/:id
5. Cleans up the /tmp/ca-supervisor-sessions.env tracking file
6. Logs the cleanup count to the session state issue

Also changed the supervisor session title convention from
"supervisor: <name>" to "[CA-AUTO] supervisor: <name>" to reliably
distinguish product-builder-managed sessions from user-created ones.
2026-04-02 14:01:36 -04:00
..