---
created: 2026-04-13T05:32:55.995Z
title: Psyche wrapper auto-recovery on empty PULSE_TRIGGER stdout
area: psyche
files:
  - src/live/psyche_wrapper.rs
---

## Problem

When Psyche's PULSE_TRIGGER returns empty stdout, something has gone wrong with the Psyche session (likely a stale or broken `--resume` session). Currently there is no recovery mechanism — the wrapper just continues with the broken state, leading to silent failures where Psyche stops functioning.

## Solution

Implement a three-tier fallback chain in the psyche wrapper when PULSE_TRIGGER returns empty stdout:

1. **Fresh session fallback**: Launch Psyche as a fresh session (no `--resume`) that gets fed memformat and context, just like a new wrapper session would upon startup.
2. **Alternative CLI fallback**: If fresh session also returns empty stdout, retry the same fresh-session approach but using `ccs` in place of `claude`. If this succeeds, **latch `ccs` as the CLI for all subsequent Psyche invocations** for the remainder of the wrapper session.
3. **Wait and retry**: If both fallbacks fail (empty stdout again), don't crash — just wait until the next PULSE_TRIGGER interval to try the entire fallback chain again.

This gives Psyche maximum chance of self-healing without manual intervention. The `ccs` latch ensures that once we discover `claude` is broken, we don't keep falling back every pulse — we stay on the working CLI.
