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.
How it works
Section titled “How it works”The two launchers
Section titled “The two launchers”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.
Which launcher a session gets
Section titled “Which launcher a session gets”zt start takes the first of these that is set:
- The
--launcherflag. - The
ZENTRI_LAUNCHERenvironment variable. - The
"launcher"key in the config file. - 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.
What runs where
Section titled “What runs where”| 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.
The policy
Section titled “The policy”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, andplatform.claude.com.codex:api.openai.com,chatgpt.com, andauth.openai.com.opencode:api.anthropic.comandapi.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 kit is managed config
Section titled “The kit is managed config”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 andallowManagedHooksOnly, and/etc/claude-code/managed-mcp.json. - Codex reads
/etc/codex/requirements.tomland/etc/codex/config.toml. - OpenCode reads
/etc/opencode/opencode.jsonand 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.
Credentials and the session token
Section titled “Credentials and the session token”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.
zt startregisters the intent and the session. The coordinator issues the session token.- The launcher makes the host worktree and the branch, and bundles the branch with
git bundle create. - The launcher renders the policy. A loopback coordinator URL such as
http://127.0.0.1:8080becomeshttp://host.openshell.internal:8080. When origin is anhttporhttpsURL, the policy keeps agit_remoterule for that one repository. - The launcher runs
openshell sandbox create --no-auto-providerswithzentri sandbox runas the main process. The git identity comes from the host repository’suser.nameanduser.email. - The launcher uploads the bundle, the prompt, and the token, and then
/tmp/zentri/ready. - In the sandbox,
zentri sandbox runwaits up to 60 seconds forready. It checks that the bundle holds only the session’s branch, clones it into/sandbox/<repo>, and removes the clone’s remote. zentri sandbox runwrites.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.
While the agent runs
Section titled “While the agent runs”| 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.
At zt done
Section titled “At zt done”zt donelooks for uncommitted work. While the agent runs, it runsgit statusin the sandbox. After the agent exits, it downloads/sandbox/.zentri-home.status. A listed file makeszt doneexit 3 and change nothing. A missing status file makes it exit 1.- The coordinator marks the session done, and the token stops working.
- 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.bundleinto a private temporary directory and refuses anything but a regular file. - The launcher runs
git -c fetch.fsckObjects=true fetch --no-tagsfor the session’s branch only. Then it runsgit merge --ff-only FETCH_HEADin the host worktree. - The launcher deletes the sandbox, and
ztdeletes 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.
What changed from the plan
Section titled “What changed from the plan”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 |
Use it
Section titled “Use it”-
Install the
openshellCLI, version 0.1.10 or later, and run a gateway. On native Linux, keep the Docker driver’s defaultsupervisor_network_mode = "host". On Docker Desktop, bridge mode is the one that ran. -
Build the image for your agent.
AGENTisclaude-code,codex,opencode, orstub, and the default isstub.Terminal window make sandbox-image AGENT=claude-code -
Run
zt doctor. It warns whenopenshellis missing or older than 0.1.10, and when Docker is not running. -
Name the providers that hold your agent’s credential, and start the session.
Terminal window export ZENTRI_OPENSHELL_PROVIDERS=my-anthropic-providerzt start --launcher openshell "Fix the typo in README.md" -
Attach, hand the agent a file, and finish.
Terminal window zt attachzt upload ~/Downloads/mockup.pngzt 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.
Platform support
Section titled “Platform support”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
0600file and appears in no process environment. /etcis read-only.curlreaches neitherexample.comnor the coordinator.- The heartbeat and the pre-edit hook reach the coordinator.
zt uploadlands in the clone.zt donebrings the commits home and deletes the sandbox, and the token then gets 401.
Limitations
Section titled “Limitations”- 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 donemarks 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, andReadyphases. In another phase, such asError, the branch comes home only whenzentri sandbox runleft 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
restendpoint 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
bwrapsandbox 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 --pushpushes from the host, with your git credentials. - An image built before M5 writes no status file, so
zt doneexits 1. Rebuild the image.
Related pages
Section titled “Related pages”- Why the coordinator is not sandboxed explains how the coordinator is protected.
- Writing OpenShell policies shows how to read and change a kit’s policy.
- Production setup covers the coordinator for a team.
- Sessions and forks explains the session that a launcher runs.
- Security hardening covers the coordinator’s host.
- Seats and API keys explains whose credential an agent uses.
- The CLI reference and the environment reference list every flag and variable.