Cloud Architecture

AI Code Execution Sandboxing: E2B, Vercel Sandbox, Daytona, and the Infrastructure Layer Coding Agents Actually Need

AI coding agents need to run untrusted, LLM-generated code safely. Learn how E2B, Vercel Sandbox, Daytona, and Modal approach Firecracker and gVisor isolation, and how to pick the right sandbox for production agentic workloads.

Diagram showing AI coding agent sending code to isolated Firecracker microVM sandbox environments in the cloud

Every team building a coding agent eventually hits the same wall. The agent generates code, you need to run it to verify it works, and suddenly you are staring at a decision that nobody warned you about during the “AI will write all your code” hype cycle: where exactly does that code execute, and how do you keep it from doing something catastrophic?

I have spent twenty years building infrastructure for things that run other people’s code. The threat model for AI-generated code is not fundamentally different from the threat model for user-submitted code in a SaaS platform or a cloud function runtime. What is different in 2026 is that the volume and velocity of that code has exploded. Coding agents are no longer curiosities. Teams are deploying them to real CI pipelines, real customer environments, and real production systems. That means the sandboxing infrastructure needs to be production-grade.

This article covers what I have learned about the current sandbox landscape, why standard containers are not enough for untrusted agent code, and how to choose between E2B, Vercel Sandbox, Daytona, and Modal for your specific use case.

Why Your Docker Container Is Not a Sandbox

Let me be direct about something that gets glossed over in most agent architecture discussions. A Docker container running on the default runc runtime shares the host kernel. That is not a security boundary. It is a namespace and cgroup boundary, which is excellent for resource isolation and process separation, but it does not protect you against a malicious or vulnerable process that exploits a kernel syscall to escape to the host.

For most containerized workloads, this is an acceptable risk. The code running inside your containers is code you wrote and trust. But LLM-generated code is different. The model does not know your production environment. It might generate code that tries to read environment variables, make outbound network calls to arbitrary endpoints, fork-bomb the host, or probe the local network. These are not hypothetical scenarios. I have seen every one of them happen in early production deployments.

The Kubernetes community learned this lesson with multi-tenant workloads years ago. Sandboxing untrusted workloads in Kubernetes with gVisor and Kata Containers is a well-understood problem at the container orchestration layer. The agent sandbox market is essentially rebuilding the same lessons as managed cloud primitives, optimized for the specific access patterns of coding agents: fast startup, short-lived execution, and tight integration with agent SDKs.

Isolation layers from shared-kernel containers to hardware-enforced microVM boundaries

The two dominant isolation approaches right now are Firecracker microVMs and gVisor. Firecracker is a lightweight KVM hypervisor that runs a full guest Linux kernel in under a second, originally built by AWS for Lambda and Fargate. It gives you true hardware-enforced VM isolation without the boot time overhead of a traditional VM. gVisor intercepts system calls at a user-space kernel layer, blocking dangerous syscalls before they reach the host kernel. Both approaches significantly raise the cost of a container escape compared to runc.

The practical difference matters for agent sandboxes. Firecracker gives you stronger isolation because you have a full guest kernel, but there is memory overhead for each sandbox. gVisor uses less memory per container but intercepts syscalls rather than fully virtualizing the kernel, so it is not the same threat boundary. For workloads where the primary concern is malicious code rather than a sophisticated kernel exploit, either approach is a meaningful upgrade from runc. For workloads where you are running genuinely untrusted code from unknown sources, Firecracker-class isolation is the appropriate starting point.

The Managed Sandbox Landscape in 2026

The market for managed agent sandboxes emerged from two directions: developer environment tooling that pivoted toward agents, and cloud compute platforms that added sandboxing as a primitive. Both are now legitimate and have production users. Let me walk through the major options.

E2B: The SDK-First Sandbox

E2B (e2b.dev) started as a coding agent IDE and pivoted to become what is probably the most developer-friendly sandbox SDK on the market today. Each sandbox runs inside a Firecracker microVM, which gives you the full-kernel isolation story. You get your own filesystem, your own network stack, and your own process tree. Nothing inside the sandbox can read your host environment variables, access your database connections, or reach resources on your private network unless you explicitly route them in.

The developer experience is genuinely good. You can spin up a sandbox from a Python or TypeScript SDK call, run commands, read/write files, expose ports, and get streaming output back. Sandboxes persist state across multiple agent turns, which matters because coding agents typically do not operate in single stateless function calls. They install dependencies, run tests, see failures, modify code, run tests again. That iterative loop needs a persistent workspace.

The billing model is per-second. As of late 2026, E2B charges based on vCPU count and memory allocation, and the sandbox keeps billing for its entire lifetime whether it is actively executing or waiting for the next agent turn. This is an important detail when you are building an agent that might pause waiting for user feedback. Idle sandbox time adds up. Always check E2B’s current pricing page before building your cost model, as these numbers move as the product matures.

E2B’s current limitation is GPUs. At the time of writing, E2B does not offer GPU-enabled sandboxes. For coding agents that need to test ML code or run numerical experiments, this is a real constraint.

Vercel Sandbox: GA Since January 2026

Vercel launched Sandbox into general availability on January 30, 2026, and open-sourced its CLI and SDK. Like E2B, each sandbox runs in a Firecracker microVM. The isolation story is similar: complete kernel separation, no access to host resources, sandboxes cannot see each other.

What distinguishes Vercel Sandbox is its tight integration with the Vercel AI ecosystem. Teams building with the Vercel AI SDK, v0, or the AI Gateway can wire in Sandbox directly. Cursor Cloud Agents, Blackbox AI, and RooCode all use Vercel Sandbox in production according to Vercel’s own documentation.

Vercel added filesystem snapshot support, which lets you capture a sandbox’s complete state and spin up new sandboxes from that snapshot. This is valuable for agents that need to explore multiple code paths in parallel. You install the base dependencies once, snapshot the environment, then fork into several parallel sandboxes that each try a different approach. This snapshot-and-fork pattern is becoming a standard architecture for coding agents that do speculative execution.

The pricing model differs from E2B. Vercel Sandbox charges only when the sandbox is actively executing rather than billing for idle time. For agents with bursty, human-in-the-loop workflows where the agent waits for user input between turns, this model can be significantly cheaper. Again, verify current pricing directly from Vercel before committing your cost model to paper.

Daytona: The Composable Computer for Agents

Daytona originally built developer environment tooling for human engineers. In 2025 and 2026, the company pivoted hard toward AI agent infrastructure. They raised a $24 million Series A in February 2026 led by FirstMark Capital, with the explicit goal of building what they call “composable computers for AI agents.”

Daytona’s pitch is flexibility. You can provision Linux containers, Linux and Windows VMs, or GPU sandboxes. Sandboxes can be paused and snapshotted at arbitrary points in execution, not just at startup. This means an agent that is partway through a complex task can be checkpointed, handed to a different agent or a human reviewer, and then resumed. That pattern is genuinely useful for long-horizon coding tasks.

Daytona is the only option in this group that offers meaningful self-hosted deployment. You can run Daytona’s control plane on your own infrastructure, on your own cloud account, and the sandbox VMs run in your own compute environment. For enterprise teams with data residency requirements or strict network isolation policies, this is a significant differentiator. E2B and Vercel Sandbox are currently managed-only offerings.

Daytona claims sub-100ms provisioning times for Linux containers in their cloud offering; take provisioning claims from any vendor as marketing until you benchmark them in your specific region and configuration.

Modal occupies an interesting position. It started as a serverless compute platform for ML workloads and added sandboxing capabilities as coding agents became a real use case. Modal is already well-known in the AI infrastructure world as a serverless GPU platform, and its sandbox product extends that foundation.

Where Modal differentiates is GPU access inside the sandbox. If your coding agent needs to test CUDA code, run model inference, or benchmark numerical compute, Modal is the only managed sandbox option with first-class GPU support. Each sandbox uses gVisor isolation rather than Firecracker microVMs, which means a different threat boundary. gVisor is a strong defense against common syscall-based exploits but is not equivalent to full VM isolation.

Modal’s billing model is more granular. Like Vercel Sandbox, Modal does not charge for idle time. This matters a lot in practice. Agents spend a lot of their time not executing: waiting for LLM responses, waiting for human review, waiting for test results to come back. You should not be paying for a running VM during those pauses.

Agent sandbox architecture showing persistent filesystem, network isolation, snapshot/restore, and multi-turn agent communication

Architectural Patterns That Actually Matter

The choice of sandbox platform matters less than getting the architecture right. I have seen teams pick the “right” sandbox product and then design their agent workflow in a way that makes the sandbox cost-prohibitive or operationally painful.

Persistent vs Ephemeral Sandboxes

The fundamental architectural question is whether your sandbox lives for the lifetime of a single operation or the lifetime of a task. Single-operation sandboxes are the obvious choice: spin one up, run a function, tear it down. This is cheap and simple.

But most coding agents do not work this way. A coding agent debugging a failing test needs to understand the current state of the repository, the test output, the error trace, and the code context. If you spin up a fresh sandbox for each tool call, you reinstall dependencies on every turn, which wastes time and money. You also lose the accumulated state of the agent’s work session.

The pattern that works in production is a long-lived sandbox per agent session. The agent’s working tree lives inside the sandbox. Each tool call executes inside the same sandbox, so the filesystem persists between turns. You pay for the sandbox’s lifetime, but you avoid reinstalling dependencies repeatedly. This is a classic latency-cost tradeoff, and for most coding workflows the persistent sandbox wins.

When you are doing speculative execution (the agent wants to try multiple approaches in parallel), the snapshot-and-fork pattern is the right choice. Snapshot the base environment after initial setup, then fork into multiple parallel sandboxes. This is currently only well-supported by Vercel Sandbox and Daytona.

Network Isolation and Egress

Do not underestimate the importance of sandbox network policy. An LLM-generated script can make outbound HTTP calls to arbitrary endpoints. This is sometimes legitimate (fetching a dependency) and sometimes not. You need to decide what your sandbox is allowed to reach.

At minimum, your sandbox should not have access to your internal network, your cloud provider’s metadata endpoint (169.254.169.254 is the classic target for SSRF attacks), your database connection strings, or any credentials in the environment. This is handled automatically by the managed platforms if you configure them correctly.

If your agent needs to install packages from npm or PyPI, you need outbound access to those registries. Some teams proxy this through an internal registry to avoid pulling from the public internet inside the sandbox, which also lets you enforce a software bill of materials policy.

For agents that need to call external APIs (to verify their code works end-to-end), think carefully about what credentials you inject into the sandbox. A sandbox that has a real API key is a much higher-value target than one that does not. Consider injecting test credentials with restricted scopes rather than production credentials.

The platform engineering work required to run AI coding agents safely at scale includes all of this network policy work. The sandbox platform gives you the isolation primitive. The policy and credential management is still your responsibility.

Timeout and Resource Limits

Coding agents will, at some point, generate code with an infinite loop or a process that consumes unbounded memory. You need hard resource limits. Every managed sandbox platform supports timeouts and memory caps. Set them conservatively at first. A sandbox that times out at five minutes and a gigabyte of RAM is a sandbox that cannot accidentally cost you a thousand dollars in a runaway session.

Watch out for the difference between per-call timeouts and session timeouts. You want a short per-call timeout (the command the agent runs should finish quickly) and a longer session timeout (the overall agent task can take tens of minutes). Most platforms support both. Configure both.

Build vs Buy for Agent Sandboxes

There is a DIY path: run Firecracker directly on your own infrastructure, manage your own sandbox lifecycle, and build your own SDK. Some teams do this. AWS built Firecracker and documented it publicly. Kubernetes has RuntimeClass support for both gVisor and Kata Containers. The primitives are all open source.

The honest assessment is that building this infrastructure correctly takes months and requires deep systems expertise. You need to manage Firecracker VM lifecycle, networking (each VM needs an IP and routing), filesystem images (what OS and tools are baked in), sandbox pooling (pre-warming VMs to hit cold-start targets), billing instrumentation, and observability. This is real infrastructure engineering.

For most teams, the managed platforms are the right answer unless you have a specific requirement they cannot meet: data residency, custom silicon, extremely high concurrency requirements at a price point that makes managed platforms prohibitive, or a specific compliance framework that requires you to control the full stack. Daytona’s self-hosted option is worth evaluating if you have data residency requirements but do not want to build from scratch.

Decision matrix for choosing AI code execution sandbox: E2B vs Vercel Sandbox vs Daytona vs Modal based on isolation model, GPU needs, self-hosting, and billing model

Security Is Still Your Job

The sandbox platforms handle the low-level isolation. They do not handle the higher-level security questions that come from the emerging threat landscape for AI agents.

A coding agent running in a Firecracker sandbox is isolated from your production infrastructure, but it can still be prompted to generate code that exfiltrates data from within its own context, sabotages the task it is supposed to complete, or produces code that looks correct but contains deliberate vulnerabilities. These are not isolation failures. They are agent behavior failures.

The sandbox is a backstop for the infrastructure-level blast radius. It does not replace prompt injection defenses, output validation, human review gates for high-consequence operations, or the kind of careful capability scoping that agentic AI systems require in production.

Think of the sandbox as the last line of defense at the execution layer, not as a comprehensive security solution. Your defense-in-depth includes: prompt design that scopes the agent’s capabilities, output validation before code is committed or deployed, RBAC for what the agent can read and write in your actual infrastructure, and audit logging of everything the agent executes.

One operational detail I cannot stress enough: rotate the credentials that live inside your agent’s context regularly. An agent session that runs for hours is accumulating context that includes any secrets you injected at the start. Treat that session like an open connection to a database: minimize what it can access and close it when the task is done.

Observability Inside the Sandbox

You cannot debug agent failures without knowing what happened inside the sandbox. Build observability in from the start.

At minimum, you want:

  • Full command execution logs with stdout and stderr per turn
  • File system change summaries so you can see what the agent wrote
  • Exit codes and timing for each command
  • Network requests the sandbox made (if your platform supports this)

E2B, Vercel Sandbox, and Daytona all provide execution logs. Modal surfaces execution logs through its standard observability tooling. None of them give you deep network observability out of the box. If you need to know exactly what outbound calls the agent made, you will need a proxy or a network tap inside the sandbox.

For teams doing LLM observability in production, the sandbox execution trace should be correlated with the LLM inference trace. You want to be able to answer: what did the model generate, what did the sandbox execute, and what was the result? That correlation lets you debug failures, audit agent behavior, and improve your prompting over time.

Which Platform Should You Use?

After spending time with all of these platforms, here is my practical guidance:

Start with E2B if you want the fastest time to a working agent sandbox, you care about Firecracker-class isolation, and you are not yet at a scale where idle billing becomes painful. The SDK quality is high and the developer experience is genuinely smooth.

Choose Vercel Sandbox if you are building on Vercel’s AI ecosystem, you want idle-time billing, or you need the snapshot-and-fork pattern for parallel speculative execution. The open-source CLI and SDK are also a plus if you want to inspect what is happening under the hood.

Evaluate Daytona if you have data residency requirements, need Windows VMs, want self-hosted control, or need GPU sandboxes with strong checkpoint and resume capabilities. The $24M Series A in February 2026 suggests they have runway to build out the product, and the self-hosted option is a genuine differentiator.

Use Modal if your agent needs to run ML code that requires GPU access inside the sandbox, or if you are already running Modal for serverless GPU inference and want a unified platform. The gVisor isolation is weaker than Firecracker but still substantially better than runc.

The right answer also depends on where you are in the product lifecycle. Early-stage teams building their first coding agent should optimize for developer experience and time to a working demo. At that stage, E2B or Vercel Sandbox are the natural starting points. Teams at scale with serious security and compliance requirements should budget the time to evaluate Daytona’s self-hosted option or build their own Firecracker-based sandbox, because the managed platforms were not designed with enterprise compliance as the primary use case.

What Is Coming Next

The sandbox market is moving fast. The OpenAI Agents SDK added native sandbox integration in 2026 with several hosted providers integrated directly. That signals that sandbox infrastructure is becoming a commodity layer, not a differentiator. I expect pricing to compress and the managed platforms to converge on similar feature sets over the next year.

The interesting differentiation will come from what happens around the sandbox: better observability tooling, tighter integration with version control and CI systems, snapshot-based parallel execution at scale, and infrastructure for multi-agent workflows where agents spawn sub-agents that need their own sandboxes.

The core technical question of “how do you safely execute untrusted code” has been solved by the hyperscalers. Firecracker is mature. gVisor is mature. What the ecosystem is still figuring out is the developer experience, the operational tooling, and the billing models that make these primitives viable for the breadth of use cases that AI coding agents are creating.

Twenty years of running infrastructure for other people’s code has taught me that isolation is necessary but not sufficient. You still need sensible defaults, clear runbooks for when things go wrong, and a security model that does not depend entirely on the sandbox never being breached. Build your agent architecture assuming the sandbox is one layer of defense, not the only one.


For a deeper look at the browser automation counterpart to this problem, the cloud browser infrastructure for AI agents guide covers Browserbase, Steel, and the web automation layer separately from code execution sandboxing. The two are often confused but serve different purposes.