Execute LLM-generated Python, JavaScript, or Bash in isolated Firecracker microVMs. No network access, no persistent state, no host escape risk.
AI agents frequently need to run code they’ve generated — for data analysis, calculations, or web scraping. Executing that code directly on the host is dangerous: a malformed or malicious script can escape the process, access the network, or consume unbounded resources. Hexr Sandbox runs each execution in a Firecracker microVM that is created fresh, given no network access, and destroyed immediately after the code finishes. This guide shows you how to use hexr.sandbox.exec for both direct code execution and the common LLM-generate-then-execute pattern.
Each execution runs in a dedicated Firecracker microVM that is created fresh and destroyed immediately after the code exits. The microVM has no network access and a read-only root filesystem.
Threat
Protection
Code escapes to host
Firecracker KVM isolation
Network exfiltration
No network access by default
Disk persistence
Read-only rootfs, destroyed after execution
Resource exhaustion
CPU, memory, and time limits enforced
Cross-agent interference
Separate microVM per execution
The sandbox has no network access by default. If your generated code attempts to make outbound HTTP requests, it will fail. This is intentional — it prevents data exfiltration from LLM-generated code.