The default is: no container
The agent class decides execution mode, not a per-turn setting:- SDK agents run in-process.
AnthropicAgent,OpenAIAgent, andHermesAgentextend the AI SDK’sToolLoopAgent; the opt-inElizaAgentwraps an elizaOSAgentRuntimein the same process. All make plain HTTPS calls to a model provider: no subprocess, no container, the agent’s “environment” is your own process. These are the only agents that run unchanged inside a JS-only serverless runtime (a Cloudflare Worker, a Vercel function). - CLI / full-OS agents run as a child process.
ClaudeCodeAgent,CodexAgent,AntigravityAgent,OpenCodeAgent, and every other CLI agent extendBaseCliAgent, spawning the vendor binary (claude,codex,opencode, …) vianode:child_process. By default that child process runs on the host, inrootDir(this.cwd ?? options?.rootDir ?? process.cwd()), the same machine driving the run. No automatic per-turn container.
A full OS environment is always opt-in: wrap the work in
<Sandbox>.Three common guesses — all reasonable, all wrong by default
Newcomers guess the same three things wrong:What you pay for — three billing axes
There is no single “cost of running an agent”: three independent axes, and a given run may touch one, two, or all three:Opting into a full OS: <Sandbox>
<Sandbox> runs a child workflow (or a single step)
inside an isolated runtime: whole-graph, per-step, or mixed, your choice. It
renders as exactly one scheduler task per boundary (not per agent turn);
children never become parent-run tasks. The runtime is pluggable
(bubblewrap, docker, codeplane, cloudflare) or any custom provider you
register, including the first-class Microsandbox provider.
The lifecycle at a <Sandbox> boundary is: create the sandbox when the task
starts → run the harness → capture a diff bundle of what changed → tear it down
(unless you keep it). Cleanup, idle timeout, and reuse are the provider’s
decision, not a Smithers-core guarantee. The Cloudflare provider, for example,
creates one container keyed ${runId}-${sandboxId}, defaults cleanup: "destroy", and can keep the container or hold it warm with keepAlive. The
Microsandbox provider exposes explicit create, start, stop, snapshot, and
cleanup semantics.
Running a CLI agent in a fresh per-turn container is a composition you
author, not a built-in switch: wrap the agent’s
<Task> in a child
workflow behind <Sandbox provider={…}>.Statefulness — warm vs cold containers
CLI agents keep credentials and resumable sessions on disk, which decides whether a cold per-turn container is viable:- API-key billing → cold containers are fine. Pass
apiKeyand the agent forwardsANTHROPIC_API_KEY/OPENAI_API_KEY; sessions are stateless per turn, so a fresh (cold) container each turn works. - Subscription billing → needs a warm/persistent environment.
ClaudeCodeAgentclearsANTHROPIC_API_KEYso the CLI bills your Claude Pro/Max subscription, reading credentials from a one-time interactive/loginat<CLAUDE_CONFIG_DIR>/.credentials.json.CodexAgentmirrors this withCODEX_HOME/auth.jsonagainst the ChatGPT subscription. A cold container has none of that on disk, so subscription mode needs the credential/session directory to persist: a sticky/warm container or a mounted credential volume.
Serverless compatibility at a glance
”Sandbox” means three different things
This overloading is the single biggest source of confusion — name the sense you mean:- Tool sandbox — the built-in tools (
read/write/edit/grep/bash) jailed torootDir, with symlinks/network/timeouts denied by default. A path/permission jail, not an OS boundary. - A CLI agent’s own internal policy — e.g. Codex’s
sandbox: "read-only" | "workspace-write" | "danger-full-access"(seatbelt/seccomp inside the vendor binary). Passed straight through to the CLI; unrelated to the other two. - The
<Sandbox>component — compute isolation: a provider-backed container/VM that runs a child workflow. This is the only one that gives an agent “a real computer.”
Read next
- Sandbox component: the JSX surface and providers.
- CLI agents: per-harness auth, billing, and sessions.
- SDK agents: in-process provider-backed agents.
- Cloudflare: Workers, Durable Object SQLite, and the sandbox provider.