Skip to main content

🧰 Backends

A backend is a sandboxing mechanism: Docker, bubblewrap on Linux, and Seatbelt on macOS. A backend is not tied to a platform. It states the primitives it needs, and those primitives decide whether it can run on this machine.

Choosing one​

The backend is chosen by the person running the code, in the user configuration outside the checkout, or for a single command:

# ~/.config/agentkit/litterbox/config.toml
backend = "docker"

[backends.docker]
image = "ubuntu:latest"
litterbox --backend docker list

Bubblewrap​

bubblewrap runs the sandbox as a holder process in unprivileged user namespaces. It needs no daemon, no root and no image. It is the backend that applies a devshell step's environment and store closure.

backend = "bubblewrap"

[backends.bubblewrap]
# Optional bounds, applied to the sandbox's cgroup scope.
memory-mb = 4096
tasks = 512

The sandbox runs the shell you name for the scripts its tools evaluate. The default is ["sh", "-c"]; if the host's userland has no sh entry, name another shell. It is resolved on the host and bound into the view, so it does not have to be on the sandbox's PATH.

[backends.bubblewrap]
shell = ["bash", "-c"]

A project must list the backend to use its provisioning steps:

# .agentkit/litterbox/config.toml
[project]
backends = ["bubblewrap"]

Bubblewrap gives the sandbox its own network namespace by default, so the only thing it can reach is its own loopback. That is right for a workload with every dependency in its closure, and wrong for one that has to fetch them.

[backends.bubblewrap]
# "denied" (the default) isolates egress; "host" shares the host's network.
network = "denied"

With network = "host" the sandbox reaches whatever the host reaches, and a listener it starts is reachable from the host. A project that declares [[ports]] needs that: with the isolated default, create refuses rather than quietly running without the ports.

The holder starts in a systemd user scope when the host has one. Without a usable scope, creation needs accept-degraded = true: pause then uses a stop-and-rescan loop instead of an atomic freeze, and nothing bounds memory or task count.

A project's .agentkit/litterbox/config.toml cannot select or configure a backend, with one exception: [backends.<name>].provision is the project-owned ordered list of provisioning steps for that backend. Every other backend key is machine-owned; if the project sets one, Litterbox reports it and ignores it, so the sandbox runs on your machine, not the maintainer's.

Seatbelt​

seatbelt confines each command with the macOS kernel sandbox. A helper binary applies a profile to a child and execs, so the command and every descendant are confined without a virtual machine, an image or a container runtime. It is macOS only.

backend = "seatbelt"

[backends.seatbelt]
# "denied" (the default) emits no outbound rule at all, loopback included.
# "host" shares the host's network.
network = "denied"
# "default" adds the lists below to the built-in OS baseline;
# "none" uses them as the exact read and service sets.
baseline = "default"
baseline-reads = []
mach-services = []

The default baseline is OS paths only: /System/Library, /System/Applications, /Library/Frameworks, /usr/bin, /usr/lib, /usr/share, /usr/libexec, /bin, /sbin, /private/etc, /private/var/db/dyld, /private/var/select and /dev. It names no Nix store and no developer directory. baseline = "none" lets you start from a narrower set and add what a workload needs, which is the way to harden the sandbox beyond the default.

Access is an allowlist: the baseline, the workspace and the paths a provisioning step contributes. Since nothing else is read, there is no credential deny list to keep current. Contributions are validated first, and a step may not contribute a path under /Users or the current user's home, the workspace, or the backend's state.

The backend has no resource limits and forwards no ports. A command that writes outside the workspace fails, and a command that needs a compiler gets one only when the project contributes the toolchain paths as read mounts; the backend does not know what Xcode is. A sandbox with no provisioning step has no PATH, because the baseline supplies files, not an environment. A devshell step contributes its environment and store closure, but the mechanism itself needs no Nix: the profile is the same with or without one. A compiler that writes a cache to the host temporary directory gets warnings and still succeeds, because the backend does not grant that directory.

The holder listens on a short-lived socket in the user temporary directory and writes holder.log in its state directory. Readiness reports the sandbox symbol, the helper's trust, a probe application and a writable state root.

A project must list the backend to use its provisioning steps:

[project]
backends = ["seatbelt"]

Seeing what this machine can run​

litterbox backends

The command lists every backend built into the binary, marks the selected one, and reports each one's readiness: available, degraded or unavailable, with the reason and what you can do about it. --json emits the same report for scripts.

* docker degraded
the Docker daemon: available
image ubuntu:latest: degraded (the image is not present and will be pulled on first use) -- pull the image ahead of time to avoid the first-create delay

A backend marked unavailable will refuse to run rather than fall back to another mechanism, and the error names what is missing.

Reading a sandbox​

litterbox list prints each sandbox with its status and the backend hosting it. litterbox backends is not exposed over MCP: an agent cannot change or probe how your machine confines code. Sandbox lifecycle explains what each status means and which operations are valid in it.