IntermediateAnalysisAI

Agent sandboxes - where unvetted code runs

The infrastructure layer that runs code an agent wrote without a human reviewing it - the isolation primitives (container, gVisor, microVM), the lifecycle a sandbox exposes, and how E2B, Modal and Daytona differ on the dimensions that actually break a deployment.

Updated Reviewed
intermediateAssumes working familiarity; skips the fundamentals.

Agent sandboxes - where unvetted code runs

An agent that writes code needs somewhere to run it that no human reviewed first - and that is the entire case for the sandbox layer. The question “is this environment isolated” sounds binary and is not: a shared process, a container, a sandboxed runtime and a microVM are four different boundaries, and the platforms sell all of them under the same word.

What a sandbox actually provides

Strip the vendor surface away and the interface is always the same shape: create an environment on demand, run code in it, get the output, destroy it. Around that core sits a lifecycle that decides whether the product fits an agent at all.

The lifecycle every sandbox exposes

  1. Create

    A fresh environment, from a template or image

    Cold start lives here - the gap between asking for a sandbox and getting a usable one

  2. Prepare

    Dependencies installed, files seeded, services up

    Readiness matters because an agent that calls exec() before the environment is ready sees a confusing failure, not a clean one

  3. Execute

    Commands and code run against it

    exec(), file I/O, an interactive session - the agent treats it as a real machine

  4. Pause / persist

    Filesystem and memory saved

    What makes a multi-step agent possible - the environment survives between turns rather than being rebuilt

  5. Destroy

    The environment is torn down

    Timeouts and idle limits exist because an agent left running is a bill and a surface

The isolation ladder

What "isolated" actually means

Every rung up costs you something in start time; every rung down costs you a boundary.

Isolation primitives ordered by boundary strength: shared process, OCI container, gVisor or Kata sandboxed runtime, Firecracker microVM, dedicated hostA ladder of five rungs, weakest to strongest. A shared process is fastest but offers no boundary at all. An OCI container shares the host kernel, so a container escape reaches the host. A sandboxed runtime such as gVisor interposes a userspace kernel, or Kata runs containers as light VMs. A microVM such as Firecracker boots a real guest kernel with a minimal device surface, the same isolation AWS Lambda uses. A dedicated host is the strongest and slowest boundary, reserved for the least trusted workloads.STRONGER BOUNDARYFASTER STARTSharedprocessno boundaryOCIcontainershares the host kernelgVisor / Katasandboxed runtimeuserspace or light-VM kernelFirecrackermicroVMreal guest kernel, minimal surfaceDedicatedhosta machine per tenantE2B and Modal run hereModal's gVisor option runs hereDaytona's default runs here
Position on the ladder is a security decision, not a performance one. A shared kernel means a container escape is a host escape; a microVM boots a real guest kernel and shrinks the device surface to almost nothing - the same boundary AWS Lambda runs on. The vendors differ most in which rung they sit on by default, and that is the first thing to check. On a narrow screen, scroll the diagram; the same ladder is written below.
  1. Shared process: fastest start, no boundary - only acceptable for code you already trust.
  2. OCI container: namespaces and cgroups on a shared host kernel; a kernel exploit escapes to the host.
  3. gVisor or Kata: a userspace kernel, or containers run as light virtual machines - a real boundary without full VM cost.
  4. Firecracker microVM: a real guest kernel on KVM with a deliberately minimal device model; the isolation AWS Lambda and Fargate use.
  5. Dedicated host: the strongest boundary, used when nothing on the machine may be shared.

The primitives differ most in what stands between the agent’s code and your host:

  • A shared process offers no boundary at all - fine for code you already trust, not for code a model just wrote.
  • An OCI container uses namespaces and cgroups on a shared host kernel. A kernel-level escape reaches the host, which is why “container” alone is not a security answer.
  • A sandboxed runtime - gVisor interposing a userspace kernel, or Kata running each container as a light virtual machine - puts a real boundary up without a full VM’s cost.
  • A microVM such as Firecracker boots a genuine guest kernel on KVM with a deliberately minimal device surface - the same isolation AWS Lambda and Fargate run on.
  • A dedicated host is the strongest rung and the most expensive: nothing on the machine is shared, reserved for the least-trusted workloads.

The vendor question to ask is not “is it sandboxed” but “which rung does the default configuration sit on” - because several platforms let you pick, and the default is not always the strong one.

The three platforms as they actually differ

The three names that recur are not interchangeable; each optimises a different axis of the same job, and the differences that matter are the ones below the feature table.

E2B Modal Daytona
Isolation by default Firecracker microVM gVisor sandboxed runtime OCI container (Kata or Sysbox opt-in)
Persistence Pause and resume with filesystem and memory kept Filesystem and memory snapshots Workspaces persist across sessions
Built for Agent code execution specifically Sandboxes as one feature of a broader serverless platform Persistent dev environments, pivoted to agents
Open source Runtime and infra are Apache-2.0 Proprietary platform Moved its production codebase closed-source in June 2026
Cold start Sub-second for a warmed template Slower, but scales to zero Fast for a workspace model

The cold-start numbers are worth a pinch of scepticism - LogRocket’s independent measurements put creation around 700 ms for E2B and Daytona and roughly 2.4 s for Modal, against vendor claims that are uniformly rosier - but the relative order holds: a coding agent that opens a sandbox per edit cares about the first number, a batch agent that runs a job does not.

What actually decides the choice

Five dimensions, and no platform wins all of them:

  • Cold start - a coding assistant that spins an environment per edit lives or dies on it; a nightly batch agent does not notice.
  • Isolation model - the rung on the ladder above, which sets the floor for the worst case.
  • Session persistence - whether the environment survives between an agent’s turns. A research agent holding a dataset across twenty tool calls needs this; a one-shot script does not.
  • SDK ergonomics - how close the API sits to the way an agent actually calls it.
  • Pricing model - per-second billing, session-scoped versus persistent, a floor versus scale-to-zero. Modal scales to zero when idle; persistent workspaces bill like a dev machine.

Match the platform to the dimension where a wrong choice breaks the agent, the security model, or the budget - that is the shortlist, and everything else is a filter. The practical takeaway is that “isolated enough” depends on what the agent is allowed to do, which is the harness’s permission model - the sandbox enforces it, but does not set it.

Where it breaks

  • The default is not always the strong isolation. A platform that offers a container as the default and a stronger primitive as opt-in is a different product from one whose default is a microVM - read the rung, not the marketing.
  • A sandbox with no egress policy is a sandbox that leaks. The isolation protects the host, not the network; an agent that can exfiltrate over HTTP from inside the sandbox is still an exfiltration path.
  • Persistence is a liability as much as a feature. A sandbox that survives between sessions also survives with whatever the agent left in it, and a leaked or poisoned state is reused on the next run.
  • The SDK is a new dependency with its own attack surface. These platforms are young - E2B’s Series A was July 2025, Daytona’s February 2026 - and their SDKs move fast enough that pinning a version is doing real work.

What this is not for

  • Running code you already trust - the overhead of a managed sandbox buys nothing when the code is reviewed; run it in your own infrastructure.
  • Anything that needs a real user environment - a sandbox is a clean room, not a workstation, and an agent that needs an actual desktop wants the computer-use pattern, not a code sandbox.
  • A substitute for the permission model - the sandbox bounds where code can run, not what the agent is allowed to ask it to do.

What to watch

Specific things that would change what this page concludes.

  • Whether sandbox APIs converge on a standard surface - each vendor's SDK is currently its own contract, and OpenAI's sandbox-partner model is an early hint at commoditisation
  • Whether the closed-source moves (Daytona, June 2026) spread to other platforms as agent workloads make the runtime itself the moat