Sandbox
The sandbox confines every shell command the agent runs inside an OS boundary — macOS Seatbelt or Linux bubblewrap — with restricted filesystem and network access. Where the permission gate decides whether a command runs, the sandbox constrains what it can touch while running — and because the boundary is enforced by the OS on the running process, it holds regardless of what the model decided to run. It cannot be talked out of with clever command strings. This is the second, independent layer of defense in depth.
The adapter is @lite-agent/sandbox-anthropic, backed by @anthropic-ai/sandbox-runtime.
Enable it
Pass sandboxRuntime() to createLiteAgent / query via the sandbox option:
From here on, every command the agent runs through the bash tool is wrapped into the OS boundary before execution — no changes to tools or middleware needed.
How it works
Sandbox is a swappable strategy in @lite-agent/core. Its core operation is a pure command-string transformation:
The core bash tool calls ctx.sandbox.wrap(command, { cwd }) right before execution, then executes the wrapped command. The wrapped string runs the original command inside the OS boundary, so the sandbox contains whatever the process actually does — filesystem writes, network connections, child processes (which inherit the boundary).
The returned Sandbox exposes initialize(), wrap(command, opts), and dispose(); the kernel calls them for you. Initialization is lazy — the sandbox runtime (including its network proxy) starts on first use. When no sandbox is configured, core defaults to noopSandbox() and commands run unwrapped.
Options
sandboxRuntime(opts) accepts SandboxRuntimeOptions:
The defaults are deliberately safe: nothing may be written outside the working directory, ~/.ssh and ~/.aws are unreadable, and no outbound network access is allowed. Opt in to more access explicitly.
Graceful degradation
The OS sandbox can't initialize everywhere — missing bubblewrap, native Windows, or an otherwise unsupported environment. sandboxRuntime handles this without blocking the agent:
- Default (
requireSandbox: false) — the adapter degrades to a no-op:wrapreturns commands unchanged, andonUnavailable(err)fires exactly once so the host can log or surface the degraded state. - Strict (
requireSandbox: true) — initialization failure throws, so a host that mandates a boundary fails fast instead of silently running unsandboxed.
Degraded mode means no OS boundary. Commands still pass the permission gate, but nothing contains them at runtime. Use requireSandbox: true where a sandbox is a hard requirement.
Defense in depth: permission gate vs. sandbox
lite-agent separates "should this command run?" from "what can it touch once running?" — two orthogonal layers that must both exist:
The gate decides before execution; the sandbox contains whatever the gate lets through. Only a gate: an approved command can still read ~/.ssh or phone home. Only a sandbox: dangerous-but-in-bounds operations never get stopped for approval. The two compose naturally — no extra orchestration needed.
With this setup: curl evil.com → blocked (domain not allow-listed); cat ~/.ssh/id_rsa → read denied; rm -rf ~/project-outside → write outside boundary, rejected by the OS. None of this relies on model cooperation.
Limitations
@anthropic-ai/sandbox-runtimeis a Beta Research Preview — its API may change, and native Windows is unsupported (WSL2 works). That is exactly why the adapter is pluggable and degrades to noop by default.- Network filtering does not decrypt TLS — it trusts the client-declared hostname, so techniques like domain fronting can bypass it. Allow-listing a broad domain (e.g.
github.com) opens an exfiltration channel. Stronger threat models need a custom MITM proxy (out of scope here). - Not for fully untrusted code — an OS-level sandbox is a guardrail for a trusted agent, not isolation for malicious code. For that, use a microVM (E2B, microsandbox) behind your own
Sandboximplementation — same interface, swappable anytime.
See also
- Permissions — the pre-execution gate that composes with the sandbox.
- Core strategies — the
Sandboxstrategy interface and thenoopSandboxdefault. - Providers — model providers to pair with.