Which sandbox is best for Mastra?
It depends on whether you want Mastra's workspace layer. For per-user agents added as plain tools, Runtime has the lowest cost of the sandboxes priced below: $34.17 for twenty thousand data questions, compared with $106.13 on Vercel Sandbox and $165.60 on E2B. It bills measured CPU, and each user's sandbox pauses with its memory kept. Pick a workspace provider Mastra lists, such as Vercel, Daytona or E2B, for Mastra's filesystem abstraction and mounts. Keep LocalSandbox for code you trust.
How does Mastra connect an agent to a sandbox?
Mastra has two routes. Its workspaces attach a sandbox provider to an agent
with workspace: new Workspace({ sandbox }). Mastra's
sandbox docs list Daytona, E2B,
Modal, Vercel and Docker among the providers. Separately, any AI SDK tool can
go straight into an agent's tools. It needs no workspace and no provider
package, and the same tools work in a plain generateText call.
| Route | Where commands run | What you add |
|---|---|---|
LocalSandbox, no isolation |
The app's own host | Nothing; Mastra calls it not secure |
LocalSandbox with bwrap or seatbelt |
The host, with writes limited | Bubblewrap or macOS Seatbelt |
| A workspace sandbox provider | That provider's machines | The provider's Mastra package |
What matters in a sandbox for Mastra?
- Per-user machines that cost nothing idle. A Mastra app usually serves many users. One named sandbox per user pauses when nothing happens. It resumes with its files, memory and processes when that user returns. This keeps each user's work apart and keeps idle hours cheap.
- Packages without a build step. An image with Python, Node.js and the
data libraries in place, where
pip installworks when the agent needs more. - Steps that can take a while. A command runs up to the timeout you give it, so a long data job is one tool call, not a polling loop.
- One tool set across frameworks. Sandbox tools written as AI SDK tools serve a Mastra agent, an AI SDK route and a workflow step alike.
What does a Mastra data agent cost per month?
Twenty thousand questions, each three minutes on a 2 vCPU, 4 GiB sandbox and busy for 30 CPU-seconds, at each provider's published rates:
| Provider | Isolation | CPU billed on | A month of questions |
|---|---|---|---|
| Runtime Cloud | Firecracker microVM | Measured use | $34.17 |
| Vercel Sandbox | Firecracker microVM | Measured use | $106.13 |
| E2B | Firecracker microVM | Every vCPU held | $165.60 |
| Daytona | Containers by default | Every vCPU held | $165.60 |
| Modal | gVisor, a shared kernel | The CPU requested | $237.96 |
When might another sandbox fit better?
- Mastra's workspace features. If you want Mastra's workspace layer itself, with its filesystem abstraction and mounts, use one of the workspace providers Mastra lists. Runtime connects as tools instead.
Runtime Cloud
With Runtime, a Mastra agent gets a full Linux microVM from one line,
tools: runtimeTools(sbx) from withruntime. It pays for CPU only while
code runs. The four tools run commands and read, write and list files in a
Firecracker microVM with its own kernel.
Sandbox.getOrCreate("user-42")gives each user one named sandbox. It pauses itself after 300 seconds with nothing happening.- The default image has Python 3.12, Node.js 24, pandas, NumPy and matplotlib.
- The tools are AI SDK tools, so the same sandbox code serves a Mastra agent, an AI SDK route and a workflow step.
The twenty thousand questions above cost $34.17 on Runtime, 68% less than Vercel Sandbox and 86% less than Modal, at rates checked 25 October 2026.
A run on Runtime, recorded 1 October 2026
TypeScriptimport { Agent } from "@mastra/core/agent";import { Sandbox } from "withruntime";import { runtimeTools } from "withruntime/ai";await using sbx = await Sandbox.create();const analyst = new Agent({ id: "analyst", name: "Analyst", instructions: "Answer with numbers you computed in the sandbox.", model: "anthropic/claude-sonnet-4-6", tools: runtimeTools(sbx),});const answer = await analyst.generate("Total revenue by region in sales.csv?", { maxSteps: 6 });console.log(answer.text);We ran this agent's generate() loop with @mastra/core 1.71.0 and the AI
SDK's mock model in place of Claude. The model's two tool calls were
scripted, and Mastra ran them against a live sandbox:
textruntime_write_file sales.csv Wrote 62 bytes to /workspace/sales.csvruntime_exec python3 -c "...groupby('region').revenue.sum()..." exitCode 0 region east 1250 south 950 west 1500pandas was there with nothing installed first. Per-user sandboxes and the rest of the API are in Mastra in a sandbox.
Sign in with npx withruntime login, and the agent above runs on free usage.
Tools that already call the E2B, Daytona or Vercel Sandbox SDK move with the
migration guide.
Sources
Checked 25 October 2026.
- Mastra sandboxes: workspaces,
the provider list and the
LocalSandboxisolation levels - Each provider's published rates, checked 25 October 2026, as the pricing guide lists them
- The recorded run: Runtime's TypeScript SDK with
@mastra/core1.71.0 andai7.0.87'sMockLanguageModelV4, against production on 1 October 2026