Skip to content

Vercel Sandbox Deep Dive: Putting the Agent Execution Layer Inside the Vercel Ecosystem

Aug 22, 20267 min
TL;DRVercel Sandbox isolates untrusted code in Firecracker microVMs and integrates with Fluid compute, Active CPU pricing, and Vercel OIDC. It fits agents already running on Vercel, but network defaults, memory billing, and persistence still require deliberate design.

Look up & save

Loading dictionary…

中文版

Vercel Sandbox is an on-demand Linux execution environment controlled through an SDK or CLI. It runs AI-agent-generated code, uploaded scripts, and test workloads. This is not a permission prompt layered onto a Vercel Function. Untrusted work moves into a separate Firecracker microVM: the agent loop can remain in a Function while shell commands, package installation, and preview servers run in Sandbox.

The product reached GA in January 2026. Vercel named v0, Blackbox AI, and RooCode as production users at launch. This article does not review the entire Vercel Agent Stack; it follows one sandbox through its lifecycle to identify when the integrated product is more useful than operating containers yourself.

Where a sandbox starts

A typical architecture has two compute boundaries:

Browser
   │ request / streamed result
   ▼
Vercel Function ── LLM / AI Gateway
   │ trusted control plane
   │ create, runCommand, stop
   ▼
Vercel Sandbox (Firecracker microVM)
   ├─ generated code
   ├─ isolated filesystem
   └─ controlled outbound network

The Function owns identity, database connections, and model credentials. The Sandbox receives only the files and network capabilities required for the job. Vercel's security architecture makes an important distinction: placing the harness and generated code in one VM still gives both the same security context. Malicious generated code could read harness credentials. Enforcing the boundary requires separate compute environments.

This also explains Fluid compute's place in the stack. Fluid suits the I/O-heavy control loop that waits for an LLM, database, or Sandbox. Sandbox handles short-lived, unpredictable, potentially hostile execution. Fluid pauses CPU billing during I/O, but Sandbox is not simply a process inside a Function: its microVM, filesystem, and lifecycle remain a separate product boundary.

Create, execute, stop: the minimum workflow

The TypeScript SDK has a compact lifecycle. A Vercel deployment can use project OIDC automatically. Local development first runs vercel link and vercel env pull; external CI uses an access token when OIDC is unavailable.

import { Sandbox } from '@vercel/sandbox';

const sandbox = await Sandbox.create({
  image: 'vercel/sandbox/node:24',
  persistent: false,
  timeout: 5 * 60 * 1000,
  networkPolicy: 'deny-all',
});

try {
  const result = await sandbox.runCommand({
    cmd: 'node',
    args: ['-e', 'console.log(6 * 7)'],
  });

  console.log(result.stdout);
} finally {
  await sandbox.stop();
}

Since SDK 3.0, a sandbox with no image specified uses the Ubuntu-based vercel/sandbox/universal image (Node.js, Python, and common coding agents included). The old runtime option (node24 on Amazon Linux 2023) is deprecated, so the example uses the equivalent vercel/sandbox/node:24; any OCI image can also be imported. The example sets persistent: false because sandboxes now snapshot automatically on stop, and a one-off job should not accumulate storage charges. Code inside the microVM may use sudo, Docker, or FUSE. Those capabilities sound broad, but they exist inside the microVM; they do not grant access to the Vercel project or host. That distinction is the product's core value.

A session defaults to five minutes. As of November 2026, Hobby permits up to 45 minutes, while Pro and Enterprise permit up to 24 hours. Work that lasts longer should not merely maximize the timeout. Divide retryable work into stages and preserve state in snapshots, persistent sandboxes, or independent storage.

Isolation does not finish the security configuration

Each sandbox has its own filesystem and network and does not automatically inherit Function environment variables, database connections, or cloud resources. That limits blast radius, but it does not decide which outbound connections are legitimate.

Network policies currently support allow-all, deny-all, and custom rules. The documented default is allow-all, so “inside a microVM” does not mean the exfiltration path is closed. A practical pattern is to allow package installation, then use update() to tighten egress to an API allowlist. When code must call an authenticated API, use egress credential brokering to inject headers outside the sandbox instead of placing secrets in environment variables.

Three other boundaries remain necessary: cap timeouts and vCPUs to control runaway consumption, avoid copying production datasets wholesale into the workspace, and validate outputs as untrusted data. A sandbox limits damage from arbitrary code execution. It does not solve prompt injection or decide whether generated SQL respects business rules.

What survives after stop?

There are two lifecycle clocks. A session determines how long one VM boot runs; persistence determines whether files survive across sessions. A snapshot records the filesystem and installed packages, then stops the source sandbox. Snapshots expire after 30 days by default, with configurable retention. A useful pattern is snapshotting a prepared node_modules tree so every job does not repeat installation.

Persistent sandboxes launched in beta in March 2026, reached GA on 2026-05-26, and are now the default. A named sandbox becomes a durable identity: stopping automatically snapshots its filesystem, and retrieving its name restores state into a new session; those automatic snapshots are still billed as snapshot storage. Another option is a Drive: separately mounted storage that survives across runs, which only one sandbox at a time can mount read-write. These remove manual snapshot orchestration, but none of them is a database. Data that must be shared across sandboxes, backed up independently, or retained long-term belongs in external storage.

Pricing has separate CPU and memory clocks

Vercel's public pricing meters Sandbox through Active CPU, provisioned memory, creations, network, and snapshot storage. As of November 2026, starting rates are $0.128 per vCPU-hour and $0.0212 per GB-hour of memory; included allowances and regional rates vary by plan.

Active CPU means waiting for an LLM or API does not incur CPU charges. It does not mean the entire sandbox is free while waiting: provisioned memory continues to accrue over session wall-clock time. This strongly favors I/O-heavy agents. A compiler or data job that holds substantial memory and saturates CPU needs an estimate based on its measured active ratio—not an unqualified application of Vercel's “up to 95%” savings claim.

Choosing: ecosystem integration is the dividing line

OptionConsider it first whenMain trade-off
Vercel SandboxNext.js or Vercel Functions already form the control plane, and OIDC, Observability, preview URLs, and Agent Stack integration matterActive CPU favors I/O waits; platform and persistence abstractions are more tightly coupled
E2BThe sandbox API should be the center of a cloud- and framework-neutral agent runtimeMore ecosystem-neutral; application deployment, identity, and observability need separate integration
Modal SandboxesSandboxes are part of a broader Python, GPU, or batch compute platformBroad compute options; a short-script Vercel web app has a longer integration path
Cloudflare Sandbox SDKThe control plane already runs in Workers and Durable Objects, alongside Cloudflare ContainersClose to Cloudflare's network; since 2026-09, SDK 1.0 has your own Durable Object control the sandbox, and 0.x is maintained only until 2026-12-31

The useful question is not “which microVM is safest?” but “who owns the control plane?” For an application already deployed to Vercel, @vercel/sandbox removes a separate identity, project mapping, and observability integration. If the agent must span clouds, schedule GPUs directly, or run on-premises, that convenience no longer determines the choice.

Conclusion

Vercel Sandbox has a precise role: a trusted application on Vercel sends untrusted execution into an independent microVM. Its advantage is not inventing sandboxing. It connects OIDC, Fluid compute, Active CPU pricing, an SDK, network policy, snapshots, and Observability into one product path.

A concrete test for tonight: create a deny-all sandbox in a test project, run the minimal Node.js command, then attempt to read a test environment variable from the parent Function and reach an external domain. Confirm that neither is available before allowing the exact files, domains, and brokered credentials the workload needs. A security boundary should begin with denial, not convenience defaults.

Update Log

  • 2026-11-23: Persistent sandboxes reached GA on 2026-05-26 and are now the default, so the example adds persistent: false; since SDK 3.0 runtime is deprecated and the default image is the Ubuntu-based vercel/sandbox/universal, so the example uses image; added Drives; updated the Cloudflare comparison row for SDK 1.0. Rates and session limits were unchanged against the official pricing page.

References