# Run troubleshooting

Look up a message or symptom from a Yokai run and find the cause and the fix: gate and contract misses, Build, recovery, timeouts and sandboxes.

Start with `yokai doctor --probe` at the repository root. For installation and first-run problems, see [Setup problems](/en/docs/koi/troubleshooting).

## Gate and contract

| Message or symptom | Cause | Fix |
| --- | --- | --- |
| Missing or incomplete phase assessment | A card has no `yokai.model-tier` or no `yokai.reason` | Approve tiers in `yokai setup` or with `/yokai assess` |
| Gate review changed or missing | The bar, a sensor or the environment changed, or an old receipt needs migration | `yokai migrate` for an old receipt; otherwise review the checks in `yokai setup` |
| Smoke review fails with a script error | Bad syntax, wrong working directory, missing tool | Fix the script or the environment and test again. Keep real product failures as they are |
| Gate red on every phase | No sensors, or a check that always fails | Run each script with `bash .koi/sensors/NN-name.sh` and fix what it reports. See [Sensors](/en/docs/yokai/sensors) |
| `gate red after phase P2 (sensor …)` though Build was green | Seal changed product code, or a test is flaky | The card is back to `todo` and `nextAction` is `/junji next`. Fix the cause and relaunch. Seal's commit stays |
| `phase P2 marked done but produced no commit` | The agent marked the card and did not commit | With recovery on, Repair commits if the gate is green |
| `phase P2 left uncommitted changes` | Build output or a stray file in the tree | Repair ignores regenerable noise; commit or delete anything else yourself |
| `phase P2 made no progress in 2 runs` | A stall | Recovery diagnoses it; or split the phase with `/junji refine` |
| Halt at a gated phase | Gated phases never run by default | Review it, then relaunch with `--allow-gated` |
| `Both BOARD.json and BACKLOG.md exist` | Two progress files | Keep the one the run uses |

## Build and recovery

| Message or symptom | Cause | Fix |
| --- | --- | --- |
| Halt before Seal with `FEEDBACK.md` present | Build did not converge and recovery is off | Read `.koi/run/FEEDBACK.md`; fix the plan or code; or set `recovery: true` |
| Diagnose keeps granting Build | The sensors stay red | Read `.koi/run/saves/`. Fix the plan or the check. Use `--max-cost` for unattended runs |
| The judge never runs | Expected while any sensor is red | Fix what the sensors report first |
| Judge blocks repeatedly | A real problem, or a preference the coder does not know | Fix the finding, or write the rule into a skill or a `build.guides` file |
| Repair skipped | `recovery: false` | Turn recovery on, or commit by hand |
| A reopened card lost its scope | Seal replaced the description with the outcome | The scope is in `.koi/run/phases/phase-NN-*.md`; Plan reuses it |

## Timeouts and quiet screens

| Message or symptom | Cause | Fix |
| --- | --- | --- |
| `waiting on sensors…` and a quiet stream | A long check is running | Wait, or raise `sensor_timeout_secs` (default 900) |
| `waiting on agent…`, gauge idle with Cursor | Cursor sends no live usage | Normal; watch the stream |
| `HALT: agent turn … timed out` | The turn ran past `agent_timeout_secs` (default 1800) | Raise it, or find why the agent hung |
| Notice: `effort … exposes no … selection` | `effort` on an agent without a reasoning selector, often Cursor | Remove `effort` from that candidate; use `speed` or `session_options` |
| `cost ceiling reached`, `token ceiling reached` | `--max-cost` or `--max-tokens` | Raise or drop the flag |
| Every candidate skipped | Login or quota problem on every candidate | Fix the agent, or wait `tiers.retry_after_secs` |

## Sandbox

| Message or symptom | Cause | Fix |
| --- | --- | --- |
| `failed to connect to the docker API` | Docker Desktop is not running | Start it and retry |
| `docker.sock` error with the Apple backend | You ran `docker build` | Use `container build -f .koi/Dockerfile.sandbox -t <tag> .` |
| `sbx` or `container` not found | The backend CLI is not installed | Install it, or use `--host` |
| `container system` warning in doctor | The Apple service is stopped | `container system start` |
| Agent not found inside the VM | The image lacks the agent | Install it in `.koi/Dockerfile.sandbox`, rebuild, recreate the sandbox |
| Tools unchanged after editing the Dockerfile | The named sandbox was not recreated | Recreate it through setup, or `sbx rm` / `container rm` |
| `image` mismatch | `sandbox.image` differs from the tag you built | Use the same tag in both places |
| `chmod … /usr/local/bin/yokai: Operation not permitted` | The Apple image ends as a non-root user | End the Dockerfile as `root` |
| Copy to `/home/agent/.local/bin` fails (Docker) | The final user cannot write there | Use the template's `agent` user |
| `no release asset at …` or `could not download …` | The launcher could not download the Linux `yokai` for this version | Check the network, or set `YOKAI_LINUX_BINARY`; see [Sandboxes](/en/docs/yokai/sandbox#linux-binaries) |
| Login works on the host, fails in the VM (Apple) | Apple VMs need their own login | `container exec -it yokai-<repo> opencode`, then `/connect` |
| `sbx` secret errors | Not logged in, or a missing secret | `sbx login`, then `sbx secret set` |
| Sandbox not created yet (probe warning) | Yokai has not run since you enabled the sandbox | Run `yokai` once, then the probe again |
| Out of memory, slow VM (Apple) | VM too small | Raise `memory` and `cpus`, then recreate; size is fixed at creation |
| Gatekeeper dialog about `mkfs.ext4` | Docker Sandboxes' bundled formatter on first `sbx create` | Start Docker Desktop first; approve only if you trust that `sbx` install |

## Working folder accidents

| Symptom | Cause | Fix |
| --- | --- | --- |
| `BOARD.json` missing mid-run | An agent ran consolidate during a turn | Restore `.koi/run/` from Git |
| Files at the repository root instead of `.koi/run/` | The agent ignored the path rule | Move them and relaunch |

## Escalation checklist

1. `yokai doctor --probe` from the repository root.
2. Run every `.koi/sensors/*.sh` by hand.
3. Read the last line of `.koi/run/ledger.jsonl`, and `.koi/run/RECOVERY.md` and `saves/` if present.
4. For Build failures, read `.koi/run/FEEDBACK.md`.
5. Check [run flags](/en/docs/yokai/run) and [recovery](/en/docs/architecture/recovery).
