koi
Documentation / architecture

Cockpit and headless

The same supervisor runs behind two front ends: a terminal cockpit you can watch and stop, and a plain text stream for CI or scripts. Neither changes what the supervisor does.

One supervisor, two views

The supervisor sends events: a phase started, an act began, a sensor failed, the agent wrote a line. A front end only displays them. Switching front ends, or themes, never changes which phase runs or how it is checked.

Cockpit Headless
Start it with yokai in a terminal yokai --headless, or any launch whose stdout is not a terminal
Shows Phase list, live agent stream, context gauge, Sessions and Deliverable views One plain line per event, plus the agent's text
Setup Opens the preparation wizard when something needs attention; p reopens it at the next phase boundary Never prompts, never writes defaults, never generates sensors
Stop and resume x stops the phase, r resumes the same run No interactive control; relaunch to continue
On a halt Shows HALT with the reason Exits with code 2

The cockpit

The cockpit is read-only: it watches the supervisor but does not pace it. The header shows the active agent and model, cumulative cost and tokens. The left column lists phases with their tiers and recent ledger rows. The body shows one of three views, cycled with w:

  • Cockpit: the live agent stream for the current phase, with Plan, Build and Seal banners and the iteration count.
  • Sessions: every agent turn the phase opened, grouped under the phase, with a context bar for each session.
  • Deliverable: the commit range a finished phase produced, as a file tree and a highlighted patch.

Under the gauge, the phase rail shows where the phase is: plan → coder → sensors → judge → seal → gate. It goes quiet during recovery.

The agent stream is not an archive. It clears at each new phase and keeps a bounded amount of text. The durable record of every turn is .koi/run/sessions.jsonl.

Stopped versus halted

The two words mean different things.

  • Stopped: you pressed x, or the agent timed out, died, or lost its connection. The run is intact. Press r to continue it.
  • Halted: the contract broke in a way the supervisor will not continue past: a cost ceiling, a gated phase without --allow-gated, or a miss with recovery: false. There is no r. Read the reason, fix the cause, and launch again.

If the machine loses power, the next yokai launch continues on its own from the card status.

Headless in practice

Headless is how a run goes on with nobody at the terminal: CI jobs, remote machines, a nohup on your laptop. It needs a fully prepared project: reviewed sensors, a tier and reason for every unfinished phase, and saved settings. If anything is missing it stops with a message instead of asking. Run yokai doctor on that machine first.

yokai --headless --max-cost 25
echo $?   # 0 when the run advanced or completed, 2 on a halt

Without --once, it runs phase after phase until a halt or the end of the board. A halt prints ⚠ halt — <reason> on stderr. If Yokai cannot start at all, for example because preparation is missing, it exits with another non-zero code before any phase runs.

Yokai sends no notifications. The exit code is the signal: wire it to an alert of your own, or let a CI job fail on it. Agent interrupts map to a halt in headless mode. Relaunch to continue; there is no --resume flag. Run on its own has recipes for tmux, nohup, alerts and GitHub Actions.

What can go wrong

  • The cockpit looks frozen with waiting on sensors…. A long test suite is running and the cockpit drops to a low frame rate while it waits. Raise sensor_timeout_secs if suites legitimately take longer than 15 minutes.
  • The context gauge says usage at turn end. OpenCode reports usage only when a turn ends. Cursor reports none, so the gauge shows the declared window size.
  • A headless job exits immediately. Run yokai doctor on the same machine; it lists what preparation is missing.

Terminal dashboard lists every key and view.