All work

MicroVM sandboxes for AI agents

Mags

Developer platform, built and run by our team

Mags is a cloud job runner and sandbox platform for teams whose AI agents run code they wrote themselves: shell commands, package installs, dev servers and headless browsers. Containers on a shared host aren't a strong enough boundary for that, and ordinary VMs boot too slowly to sit inside an agent loop. We built a Go control plane that schedules jobs across bare-metal hosts. Each run is a copy-on-write clone of a pre-booted "golden" Firecracker snapshot, with workspaces that persist between runs. The same platform runs cloud Chromium browsers, sleeps idle VMs and wakes them on demand, and deploys apps from an image or a repo. Developers use it through an npm CLI, Python and Node SDKs, a REST API or a web dashboard.

Visit the live product
mags
Mags

At a glance

Product type
Developer infrastructure: sandboxes, a job runner, cloud browsers and app deploys on microVMs
Problem
Agents execute untrusted, generated code; containers don't isolate it well enough, and full VMs boot too slowly for an agent loop
Solution
Firecracker microVMs cloned from golden snapshots, persistent workspaces on object storage, and a scheduler that sends each job back to the host where its workspace is warm
Timeline
About 13 months of continuous development, live throughout
Engineering
229 commits in the core repo, ~81,000 lines of Go, 27 database migrations, 47 test files, a public npm CLI, Python and Node SDKs
Stack
GogRPCPostgreSQLRedisFirecrackerJuiceFS / NFSS3Chromium CDP

The challenge

Coding agents, browser agents and data agents all do something risky: they run output they generated themselves. Teams building them kept running into the same problems.

Isolation

A shared container kernel isn't a safe boundary for untrusted code from many tenants.

Speed

A VM that boots in tens of seconds is fine for CI and far too slow for an agent that runs a command every few seconds.

State

Some runs should be thrown away; others need packages, databases and files still there tomorrow.

Operations

VMs crash, hosts restart and images change, and the control plane must agree with what is actually running.

Regulated buyers

Some customers need data residency, egress control and the option to run everything on their own servers.

What we built

1

Control plane and scheduler

  • A Go orchestrator over REST and gRPC that validates and meters jobs and enforces per-user and per-key quotas.
  • Memory- and disk-aware placement that prefers the host already holding the workspace, with fallback.
  • Idempotent job submission, maximum lifetimes, timeouts and callback webhooks.
2

Fast starts from golden snapshots

  • For each image type (base, Python, Chromium, coding agent, media), one VM boots and is snapshotted as a golden.
  • New sandboxes are copy-on-write clones over a shared read-only base, with network identity rewritten and clocks resynced on restore.
  • Each golden records a fingerprint of its source image and is rebuilt automatically when stale, then smoke-tested.
3

Persistent workspaces, sleep and wake

  • Workspaces live in object storage with fast local writes on top.
  • After a job the VM stays parked with its workspace mounted, and the next job for that workspace goes to the same host. In our benchmarks repeat runs dropped from about 4 s to about 0.1 s.
  • Idle VMs are checkpointed and stopped; the next SSH connection restores them on a healthy host.
4

Cloud browsers, deploys and interfaces

  • Chromium microVMs with a CDP endpoint that works with Playwright and Puppeteer.
  • One-command deploys from a Docker image or repo to an HTTPS app, with rollbacks and a self-deploy mode for the customer's own servers.
  • A CLI for runs, named workspaces, SSH-able VMs, cron and diagnostics, plus SDKs and a REST API.
5

One execution path

  • The platform started with two engines, and fixes kept regressing between them.
  • We removed the older engine completely, along with its API and CLI switches, leaving one path to test, secure and operate.

Security and operations

  • Cross-tenant network isolation for sandboxes, on the control plane and on storage exports.
  • Per-job egress allowlists, and scoped app keys with per-key job isolation and quotas.
  • Per-job secrets masked in logs; browser sessions locked to a per-session secret.
  • Self-healing: agents re-adopt VMs after a restart, a sweeper reaps crashed processes, and a two-way sync keeps the orchestrator and hosts in agreement.

Results

Live at mags.run

A public CLI on npm, SDKs and a dashboard.

Used by our own products

KiteReach renders every reel and film inside a Mags sandbox.

VM isolation, container-like starts

Golden-snapshot cloning and workspace-aware scheduling make sandboxes fast enough for an agent loop.

A simpler core

Removing the second engine left one execution path to test, secure and operate.

Key takeaways

  1. 1

    The fastest boot is no boot. Cloning a pre-booted snapshot, not booting faster, is what makes sub-second starts possible.

  2. 2

    Treat the scheduler as part of the cache. Sending a job back to the host where its workspace is warm turned a simple pool into a large speed-up for repeat runs.

  3. 3

    Delete the second path. Two execution engines doubled the bugs. Removing one was worth more than any new feature.

Have a process like this?

Tell us what is costing your team the most time. We will show you how we would scope it, build it and get it into production.