Sandbox mode
In sandbox mode the host yokai starts a Linux VM and runs a second yokai inside it. The agent and the sensors run in the VM, and your repository is mounted at the same path.
Why a sandbox
Unattended runs default to approve-all: the agent may run any command. A sandbox limits what that can reach and gives every run the same tools, defined in a file your repository owns. The next person who clones the repository can build the same environment.
Sandbox mode is optional. Without it, Yokai runs on your machine with whatever is installed there.
How it fits together
Two yokai processes take part. The one you start on the host is the launcher. The one inside the VM is the real supervisor.
When sandbox.enabled is true and you did not pass --host, the launcher:
- Creates the named sandbox from your image if it does not exist. The name defaults to
yokai-<repository folder>. - Copies a Linux build of
yokaiinto the VM:/home/agent/.local/bin/yokaiwith Docker Sandboxes,/usr/local/bin/yokaiwith Apple Container. - Runs
.koi/sandbox-setup.shonce, if it exists, and records that it ran. - Starts the inner
yokaiwithYOKAI_SANDBOX_INNER=1, forwarding your launch flags. That variable stops the inner process from starting another sandbox or opening setup.
The repository is mounted read-write at the same absolute path as on the host. Changes the agent makes inside the VM land in your checkout directly. The VM can reach the network.
Backends
| Backend | Setting | Host tool | Notes |
|---|---|---|---|
| Docker Sandboxes | backend: docker (default) |
sbx, with Docker Desktop running |
Credentials can come from the host through sbx secret |
| Apple Container | backend: apple |
container, macOS 26 on Apple silicon |
Defaults to 8 GB of memory and 4 CPUs; you sign the agent in inside the VM |
The image
The image is built from .koi/Dockerfile.sandbox, a file in your repository. It must install the coding agent you configured and every tool your sensors call. Yokai does not install agents for you. Setup can propose a Dockerfile; Approve and build saves it, builds the image and replaces the named sandbox.
# .koi/yokai.yml
sandbox:
enabled: true
backend: docker
image: daylist-sandbox
.koi/sandbox-setup.sh is an escape hatch for setup the image cannot do. Prefer the Dockerfile.
Linux binaries
The VM needs a Linux yokai of the same version as the host binary. The launcher finds one in this order:
- The path in
YOKAI_LINUX_BINARY, if set. - A cached copy for this version at
${KOI_DATA_DIR:-~/.local/share/koi}/bin/yokai-linux-<arch>-v<version>. - A download of
yokai-<arch>-unknown-linux-musl.tar.xzfrom the GitHub releasev<version>, checked against its.sha256and then cached. - An older local build at
${KOI_DATA_DIR:-~/.local/share/koi}/bin/yokai-linux-<arch>, only if the download fails.
<arch> is the host's architecture, aarch64 or x86_64, because the VM runs the host's. Pinning the version keeps the supervisor inside the VM identical to the one on the host. yokai doctor reports which copy the next launch will use. Sandboxes covers the dev-build case.
Gate review and the environment
Sensors are reviewed in the environment they will run in. The review fingerprint in .koi/yokai.yml covers the backend, the image, the Dockerfile and the setup hook. Switching from host to sandbox, or rebuilding the image, needs a new smoke run of the same scripts before Yokai runs a phase.
What can go wrong
opencode not foundinside the VM. The image does not install the agent. Add it to the Dockerfile, rebuild and recreate the sandbox.- The image changed but the tools did not. An existing sandbox keeps its old filesystem. Recreate it through setup, or remove it with
sbx rm(Docker) orcontainer stopandcontainer rm(Apple). no release asset at …orcould not download …. The launcher could not fetch the Linuxyokai. Check the network, or setYOKAI_LINUX_BINARYto a Linux build.- The host login works and the VM login fails. With Apple Container, sign in inside the VM, for example
container exec -it yokai-daylist opencodeand then/connect.
To run one launch on the host anyway, use yokai --host. Sandboxes is the step-by-step guide.