Skip to content

The sandboxing model

A launcher decides where zt start runs the agent. Zentri has two launchers. local-dev runs the agent on your machine, as your user. openshell runs the agent in an OpenShell sandbox, where a policy limits the files the agent can write and the hosts it can reach.

The sandbox limits what a hostile prompt or a hostile repository can do through the agent. It keeps the agent out of your home directory and off hosts the policy does not list. The coordinator runs outside any sandbox. Why the coordinator is not sandboxed covers what protects it instead.

local-dev openshell
Where the agent runs A tmux session on your machine A sandbox on an OpenShell v0.1.10 gateway that you run
Whose permissions Your user’s uid 1000 in the sandbox, under Landlock
Working copy A git worktree under $ZENTRI_WORKTREE_ROOT, else $XDG_DATA_HOME/zentri/worktrees, else ~/.local/share/zentri/worktrees A clone at /sandbox/<repo>, made from a git bundle
Network Any host Only the hosts that the kit’s policy lists
What you need git and tmux The openshell CLI, a gateway, Docker, and an image that you build

Both launchers make a host worktree on a new branch, zentri/<slug>-<id8>. In local-dev the worktree separates only git state. The agent runs from an argument vector, never a shell string.

zt start takes the first of these that is set:

  1. The --launcher flag.
  2. The ZENTRI_LAUNCHER environment variable.
  3. The "launcher" key in the config file.
  4. The default, local-dev.

zt start refuses a launcher name it does not know. With openshell, the agent command also picks the image. The tag is the zentri version.

Agent command Kit Image
claude claude-code zentri-agent-claude-code
codex codex zentri-agent-codex
opencode opencode zentri-agent-opencode
zentri-stub-agent stub, a scripted agent for tests zentri-agent-stub

With openshell, zt start refuses any other agent command, because no kit maps to it.

On the host In the sandbox
zt start, zt attach, zt upload, and zt done zentri sandbox run, the sandbox’s main process
The openshell CLI and the gateway The agent, in the tmux session zentri-<id8>
The host worktree and its branch A clone of that branch at /sandbox/<repo>, with no remote
The session token file that zt start writes The hooks, the MCP server, and the heartbeat, which all run /usr/local/bin/zentri

The launcher drives OpenShell through the openshell CLI. ZENTRI_OPENSHELL names another CLI binary. The launcher refuses a CLI older than 0.1.10, and it counts a pre-release such as 0.1.10-dev as older.

Each kit has a policy template in sandbox/openshell/policies/<kit>.yaml. The launcher renders it for each session with the coordinator’s host and port. Egress that the policy does not list is denied, and every endpoint sets enforcement: enforce. All four templates run the agent as uid and gid 1000 and set landlock.compatibility: hard_requirement. They give the agent these paths:

Path Access What is there
/usr, /lib, /etc, /opt Read-only git, tmux, zentri, the agent binary, and the kit
/sandbox Read and write The home and working directory, with the clone at /sandbox/<repo>
/tmp Read and write /tmp/zentri/repo.bundle, /tmp/zentri/prompt, and /tmp/zentri/ready
/var/lib/zentri Read and write, mode 0700, owned by uid 1000 session.token, mode 0600
/dev/pts, /dev/ptmx Read and write Terminals for tmux

The sandbox runs with NoNewPrivs set and seccomp in filter mode. The network rules name the binary that may use each host:

Rule Host Requests allowed Binary
zentri_coordinator The coordinator’s host and port Any method on /v1/** and /mcp, and GET /healthz /usr/local/bin/zentri
Vendor The kit’s vendor hosts, port 443 All, except on chatgpt.com, where only /backend-api/** is allowed /usr/local/bin/<agent>
git_remote Origin’s host and port, only when origin is an http or https URL GET <repo path>/info/refs*, and POST to git-upload-pack and git-receive-pack /usr/bin/git

The vendor hosts are these:

  • claude-code: api.anthropic.com, claude.ai, claude.com, and platform.claude.com.
  • codex: api.openai.com, chatgpt.com, and auth.openai.com.
  • opencode: api.anthropic.com and api.openai.com.
  • stub: none.

No package registry is allowed, and the coordinator’s /metrics is not in the allowlist. A rule also covers the processes that its binary starts, so a command the agent runs can reach the agent’s vendor too. make lint runs scripts/check-openshell-policies.sh, which fails on an endpoint without enforcement: enforce or on a placeholder left in a template. Writing OpenShell policies shows how to read and change a policy.

The image renders the kit at build time, as root, with zentri kit render --target sandbox --agent <kit> --out /. The files land under read-only /etc:

  • Claude Code reads /etc/claude-code/managed-settings.json, which sets the hooks and allowManagedHooksOnly, and /etc/claude-code/managed-mcp.json.
  • Codex reads /etc/codex/requirements.toml and /etc/codex/config.toml.
  • OpenCode reads /etc/opencode/opencode.json and the plugin it names.

The agent cannot remove its hooks or its MCP server. In a sandbox the pre-edit hook reads edits_fail_open only from ZENTRI_EDITS_FAIL_OPEN, which the launcher sets when it creates the sandbox. The image also holds the marker /etc/zentri/sandbox, a root-owned regular file that no one else can write. zentri sandbox run refuses to start without it.

Zentri never collects, stores, proxies, or resells your model access or credentials. An agent in a sandbox gets its credential from an OpenShell provider that you create on the gateway. Name your providers in ZENTRI_OPENSHELL_PROVIDERS, separated by commas. Each name must match ^[A-Za-z0-9][A-Za-z0-9._-]{0,62}$. The launcher passes --no-auto-providers, so the sandbox gets those providers and no others.

The session token reaches the sandbox only as a file, /var/lib/zentri/session.token. The launcher passes the file’s path in ZENTRI_SESSION_TOKEN_FILE, and it refuses any environment value or agent argument shaped like a token. The agent runs as uid 1000 too, so it can read the file. The token works for one session only. It expires after 8 hours, a refresh extends it up to 24 hours after issue, and zt done revokes it.

  1. zt start registers the intent and the session. The coordinator issues the session token.
  2. The launcher makes the host worktree and the branch, and bundles the branch with git bundle create.
  3. The launcher renders the policy. A loopback coordinator URL such as http://127.0.0.1:8080 becomes http://host.openshell.internal:8080. When origin is an http or https URL, the policy keeps a git_remote rule for that one repository.
  4. The launcher runs openshell sandbox create --no-auto-providers with zentri sandbox run as the main process. The git identity comes from the host repository’s user.name and user.email.
  5. The launcher uploads the bundle, the prompt, and the token, and then /tmp/zentri/ready.
  6. In the sandbox, zentri sandbox run waits up to 60 seconds for ready. It checks that the bundle holds only the session’s branch, clones it into /sandbox/<repo>, and removes the clone’s remote.
  7. zentri sandbox run writes .zentri/ with the git hooks, starts the heartbeat, and starts the agent in tmux with the prompt as its last argument.

When the create or an upload fails, the launcher deletes the sandbox and removes the worktree and the branch.

Command What it runs
zt attach openshell sandbox exec with a TTY, into the agent’s tmux session
zt status openshell sandbox get --output json. The phases Provisioning, Starting, and Ready count as alive.
zt upload FILE openshell sandbox upload --no-git-ignore to /sandbox/<repo>/.zentri/uploads/<name>. FILE must be a regular file of at most 50 MiB.

When the agent exits, zentri sandbox run bundles the branch to /sandbox/.zentri-home.bundle. It writes the clone’s git status to /sandbox/.zentri-home.status.

  1. zt done looks for uncommitted work. While the agent runs, it runs git status in the sandbox. After the agent exits, it downloads /sandbox/.zentri-home.status. A listed file makes zt done exit 3 and change nothing. A missing status file makes it exit 1.
  2. The coordinator marks the session done, and the token stops working.
  3. The launcher brings the branch home. If the agent still runs, the launcher bundles the branch in the sandbox first. It downloads /sandbox/.zentri-home.bundle into a private temporary directory and refuses anything but a regular file.
  4. The launcher runs git -c fetch.fsckObjects=true fetch --no-tags for the session’s branch only. Then it runs git merge --ff-only FETCH_HEAD in the host worktree.
  5. The launcher deletes the sandbox, and zt deletes the host token file.

When the branch cannot come home, the launcher keeps the sandbox, and zt done keeps the session, so you can run zt done again. The error names the command that drops the work, openshell sandbox delete zentri-<id8>.

After the agent exits, nothing in the sandbox can commit. zt done --discard drops the uncommitted files with the sandbox, after the commits come home. zt lists the files and asks on a terminal, and --yes skips the question. Without a terminal or --yes, it exits 2 and changes nothing. --discard never drops work in a local worktree or in a sandbox whose agent still runs.

ADR-0004 in the repository was the plan. ADR-0008 and docs/architecture/sandbox.md describe what was built. This page follows the code where they differ.

ADR-0004 planned The code does
A workspace at /workspace A workspace at /sandbox
Copy the worktree in with --upload Clone the session’s branch from a git bundle
Push the branch out from the sandbox Download a bundle at zt done and fast-forward the host branch
The session token in --env The session token as a 0600 file
The launcher kind on the session row Not recorded
Published images Images built on your machine, never pulled or pushed
  1. Install the openshell CLI, version 0.1.10 or later, and run a gateway. On native Linux, keep the Docker driver’s default supervisor_network_mode = "host". On Docker Desktop, bridge mode is the one that ran.

  2. Build the image for your agent. AGENT is claude-code, codex, opencode, or stub, and the default is stub.

    Terminal window
    make sandbox-image AGENT=claude-code
  3. Run zt doctor. It warns when openshell is missing or older than 0.1.10, and when Docker is not running.

  4. Name the providers that hold your agent’s credential, and start the session.

    Terminal window
    export ZENTRI_OPENSHELL_PROVIDERS=my-anthropic-provider
    zt start --launcher openshell "Fix the typo in README.md"
  5. Attach, hand the agent a file, and finish.

    Terminal window
    zt attach
    zt upload ~/Downloads/mockup.png
    zt done

To make openshell your default, set ZENTRI_LAUNCHER=openshell or "launcher": "openshell" in the config. The CLI reference lists every flag, and the environment reference lists the variables.

According to ADR-0004, OpenShell runs on Linux hosts (Debian and Ubuntu, amd64 and arm64) and on macOS on Apple Silicon through Docker Desktop. WSL 2 is experimental. Windows hosts cannot run the openshell launcher.

Host Result
macOS 15.7.9 arm64, Docker Desktop 29.3.0, supervisor in bridge mode make e2e-openshell passed five times on 2026-11-29
GitHub ubuntu-latest, x86_64, supervisor on the host network Passed in run 46319718637
Linux arm64, rootless Docker, or a Linux gateway in bridge mode Not run

A sandbox starts in about 4 seconds once its images are cached. The test runs the stub agent in a real sandbox and checks these points:

  • The token is a 0600 file and appears in no process environment.
  • /etc is read-only.
  • curl reaches neither example.com nor the coordinator.
  • The heartbeat and the pre-edit hook reach the coordinator.
  • zt upload lands in the clone.
  • zt done brings the commits home and deletes the sandbox, and the token then gets 401.
  • The agent can read its own token file.
  • The agent can send what it reads to its vendor’s hosts. A policy cannot read the meaning of an API request, so that channel stays open.
  • zt done marks the session done before the launcher stops the sandbox. If the agent still runs, the hook then refuses every edit, even in a project that fails open.
  • The launcher bundles the branch only in the Provisioning, Starting, and Ready phases. In another phase, such as Error, the branch comes home only when zentri sandbox run left a bundle. Otherwise the launcher keeps the sandbox.
  • Only commits come home. The merged files land in the host worktree, where a tool that runs repository files, such as direnv or a build, would run the agent’s code.
  • A rest endpoint refuses a WebSocket upgrade with 403, so an agent has to use its HTTP transport. Git over SSH is not allowed.
  • The vendor rules match /usr/local/bin/<agent> as a regular file, because OpenShell matches the real path and not a symlink.
  • On native Linux, a coordinator on loopback needs the supervisor on the host network. A gateway in bridge mode there needs the coordinator on the Docker bridge, which is untested. Zentri cannot see the gateway’s mode, so it cannot warn you.
  • Whether Codex’s own bwrap sandbox starts inside OpenShell is not known.
  • Codex still lets an edit through when its hook binary is missing.
  • The clone has no remote, and the sandbox holds no git credential unless a provider supplies one. zt done --push pushes from the host, with your git credentials.
  • An image built before M5 writes no status file, so zt done exits 1. Rebuild the image.