Guide
How to run AI-generated code safely
Run it somewhere it can't hurt anything: a fresh, isolated computer per task, with a time limit, no secrets, and no way to reach your network. Here's what that means in practice.
Is it safe to run code an AI agent wrote?
Not on your own machine. Agents make mistakes (deleting the wrong folder, installing the wrong package) and can be steered by text they read on the web, so treat their code as untrusted.
The fix isn't to read every line. It's to run every task somewhere disposable, so the worst case is a sandbox you throw away.
Why isn't a Docker container enough?
Containers share the host's kernel, so one kernel bug can let code escape to the host and to every other container on it.
A microVM gives each sandbox its own kernel behind a hardware virtualization boundary. Jasmine uses Firecracker, the same VM monitor AWS Lambda uses, and still starts sandboxes faster than Docker on the same machine (see the benchmarks).
What should a safe sandbox block?
At minimum: other sandboxes, the host's own services, and the cloud metadata endpoint (which hands out credentials).
Jasmine also blocks outbound email (port 25), gives every command a timeout, and keeps no secrets inside the sandbox unless you pass them in. An end-to-end test checks the network rules on every push.
How do I run AI-generated code in a sandbox?
Create a sandbox, run the code with a timeout, read the output, and delete the sandbox.
from jasmine_sdk import Jasmine # sdk/python, standard library only
with Jasmine().create() as sbx: # a fresh microVM, ready in ~0.1 s
r = sbx.exec("python3 -c 'print(6*7)'", timeout_ms=10_000)
print(r.stdout) # deleted when the block endsThe TypeScript SDK has the same shape (await using sbx = await new Jasmine().create()), and underneath it's plain HTTP, so any language works.
Won't a sandbox per task be slow?
Not if it isn't booted. Jasmine restores each sandbox from a memory snapshot of a machine that already booted, so it's ready for its first command in about a tenth of a second.
Commands then take a few milliseconds each, and you can pause a sandbox between agent turns so it uses no CPU.
Related
- How to give Claude Code, Codex or Cursor a sandbox
- What is a microVM? (and how is it different from a container?)
- How much does a sandbox for AI agents cost?
- The best sandboxes for AI agents, measured
Updated 2026-11-25.
Try it in a minute
Self-host it with one command, free. Jasmine Cloud, the hosted version, is in early access.