> ## Documentation Index
> Fetch the complete documentation index at: /docs/llms.txt
> Use this file to discover all available pages before exploring further.

# Sandbox a worker

> Run headless workers in a devcontainer that reaches shared Footnote state only through the daemon.

A worker can damage shared state: the worker registry, the claim lockfiles, the ledger. Sandboxing puts each `--as headless` worker in a devcontainer, a Docker container built from the repository's `.devcontainer` config. The sandbox holds the worktree and a socket to the Footnote daemon. It never holds `~/.fno`, so the worker changes shared state only through daemon operations.

The host keeps everything else: the spawn gates, the claims, the mail. Only the harness process enters the sandbox.

A harness is the CLI a worker runs, such as `claude`. A substrate is the launch shape: `thread`, `pane`, `cloud`, or `headless`, which is one task with no terminal. The daemon is Footnote's background process. The `fno` client starts it on demand, and the sandbox reaches it over a unix socket.

Sandboxing is fail-closed. When Footnote cannot build the sandbox or the probe inside it fails, nothing spawns and nothing runs on the host.

> **Warning:** A sandbox is not a security boundary. Do not use it to run code you do not trust. A worker that can reach the daemon socket can ask the daemon to run commands on the host. Sandboxing does not restrict network access.

> **Warning:** Every sandbox mounts the same socket directory. A sandbox can read another worker's credential file before that worker's sandbox deletes it.

> **Warning:** Sandboxing does not protect your project folder. A sandboxed worker can change its files, including uncommitted work. Sandboxing does not review the worker's code.

## Before you begin

* Install Footnote through the [quickstart](/docs/quickstart.md). It puts the `fno` CLI on your PATH.
* Start Docker, and provide Node, npm, and the devcontainer CLI. Your agent can install the CLI in the next section if it is missing.
* Give the repository a devcontainer config at `.devcontainer/devcontainer.json`, and commit it. A linked worktree does not see untracked files, and the sandbox builds on the worktree. The image contract is small. The `fno-agents` binary and every harness binary you plan to spawn must run on its PATH. Footnote ships no image recipe yet, so building one is on you. A Linux image cannot reuse a macOS host binary.

You sandbox workers per project. The key lives in that project's `.fno/config.toml`, and the checkout you spawn from reads its own file. When the project does not have one yet, create the file.

## Turn sandboxing on

```text theme={"theme":{"light":"min-light","dark":"min-dark"}}
Configure this project to run headless F[no] workers in its devcontainer sandbox. Show me the config change and verify it.
```

Your agent installs the devcontainer CLI if needed and adds the sandbox setting. You see the config value and any refusal.

### What the agent runs

If the devcontainer CLI is missing, your agent installs it with:

```bash theme={"theme":{"light":"min-light","dark":"min-dark"}}
npm install -g @devcontainers/cli
```

The install needs Node and npm.

Add the `[sandbox]` table to `.fno/config.toml` in the project root:

```toml theme={"theme":{"light":"min-light","dark":"min-dark"}}
[sandbox]
provider = "devcontainer"
```

`fno config set` does not know this key yet. The command refuses it:

```
error: unknown config key 'sandbox.provider'
```

Edit the file by hand instead, then read the file back to confirm the table is there.

> **Warning:** The default is `provider = "none"`, which runs every worker on the host with your own permissions. A value other than `none` or `devcontainer` refuses every spawn with exit 2. Sandboxing never silently turns itself off.

## Spawn a sandboxed worker

```text theme={"theme":{"light":"min-light","dark":"min-dark"}}
Start a sandboxed headless Claude worker to fix the failing test we discussed. Ask me which test if that is unclear. Report its session and container.
```

Your agent starts the headless Claude worker through the sandbox. You see its session and container.

### What the agent runs

Spawn as usual, with `--as headless`. `-H` names the harness, and the image must carry it:

```bash theme={"theme":{"light":"min-light","dark":"min-dark"}}
fno agents spawn -H claude --as headless "Fix the failing test in auth.spec.ts"
```

Before the harness starts, Footnote asks the daemon for a launch plan. It runs `devcontainer up` on the worktree with the plan's mounts. Then it probes the sandbox by running `fno-agents status` inside it. Probe exit 0 arms the sandbox, and the harness runs under `devcontainer exec`.

You now have a session like any other spawn. Run `fno agents session list` to see it. While the worker runs, `docker ps` lists its container. That container is the sandbox.

One visible difference exists, and it concerns `codex` only. A sandboxed `claude` session pushes its transcript to the daemon over the socket, so its activity reads on the host as usual. A sandboxed `codex` session cannot push its transcript, so its activity reads as unknown rather than idle.

Worker credentials travel in a `0600` file in the socket directory, never on the command line. A command line is readable by every user on the host.

## What the sandbox cannot reach

* Backlog, claims, and mail do not cross the socket. From a sandbox the daemon serves only agent and channel operations. A sandboxed worker reports through its session, not through `fno backlog`.
* Thread, pane, and cloud spawns refuse with exit 2. Sandboxing is for `--as headless` only.
* Some macOS Docker hosts do not pass a host unix socket through a bind mount. OrbStack 29.8.2 is one. The probe refuses there, so no worker starts.

The refusal below uses `claude` and `thread` as the requested harness and substrate. Other requests print their own values.

## Refusals and fixes

```text theme={"theme":{"light":"min-light","dark":"min-dark"}}
Diagnose the sandbox refusal we are discussing. Ask for the exact message if you cannot see it, then recommend a safe fix.
```

Your agent matches the refusal to the cases below and reports the fix.

### What the agent runs

| What you see | What it means | What to do |
| - | - | - |
| `[sandbox] provider must be "none" or "devcontainer", got ...` | The key holds a value Footnote does not know. | Fix the spelling in `.fno/config.toml`. |
| `[sandbox] provider = "devcontainer" sandboxes only --as headless spawns of claude, codex, gemini, opencode, agy; a claude spawn on the thread substrate would run on the host. Spawn with --as headless, or set [sandbox] provider = "none".` | You spawned on the thread, pane, or cloud substrate. | Spawn with `--as headless`, or set `provider = "none"`. |
| The probe inside the sandbox exits 127 | The image has no `fno-agents`. | Rebuild the image with `fno-agents` on its PATH. |
| A refusal with exit 84 naming `devcontainer up --remove-existing-container` | The probe failed or a stale sandbox answered. | Run `devcontainer up --workspace-folder . --remove-existing-container` from the project root, then spawn again. |
| A refusal with exit 84 naming a host path | The worker's command named a path outside the worktree, such as a routed `--settings` file. | Keep the command's paths inside the worktree. |
| The probe refuses on a macOS Docker host | The host does not pass unix sockets through bind mounts. | Use a Docker host that passes the socket, or set `provider = "none"`. |

The design notes in the Footnote repository carry the full mechanics, including why the socket directory is mounted instead of the socket file. See `docs/architecture/sandbox-host.md` there.

## Next steps

* [Run a fleet](/docs/guides/run-a-fleet.md): spawn and watch several workers, sandboxed or not.
* [Recover a worker](/docs/guides/recover-a-worker.md): inspect a quiet sandboxed session before you replace it.
* [Run a demo in a sandbox](/docs/guides/demo-sandbox.md): get a disposable install with its own logins for demos, not for workers.
* [Troubleshooting](/docs/troubleshooting.md): separate a missing tool from unfinished work.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.