Skip to main content

Why SmolVM for AI Agents?

When AI agents generate and execute code, you need strong isolation to prevent:
  • Host compromise - Malicious code escaping to your system
  • Data exfiltration - Unauthorized access to sensitive files
  • Resource abuse - Uncontrolled CPU/memory/network usage
  • Persistent side effects - State pollution across tasks
SmolVM provides hardware-level isolation using Firecracker microVMs, making it significantly more secure than Docker containers.

Security Benefits

Hardware Isolation

KVM-based virtualization provides stronger isolation than containers. Escape requires a hypervisor exploit, not just a kernel vulnerability.

Controlled Networking

Fine-grained control over guest internet access. Restrict or monitor all network traffic.

Ephemeral Environments

Spin up a fresh VM for every task and destroy immediately after. No persistent state between tasks.

Resource Limits

Strict CPU and memory limits prevent resource exhaustion attacks.

Integration Pattern 1: Tool/Function Calling

Wrap SmolVM as a tool that your AI agent can invoke:

Integration Pattern 2: Long-running Agent Environments

For agents that need persistent state across multiple interactions:
1

Create a persistent VM

2

Reconnect for each agent task

3

Clean up when done

Integration Pattern 3: Web Browsing Agent

Provide agents with isolated browser environments:

Real-world Example: OpenClaw Agent Environment

From examples/openclaw.py - complete integration with the OpenClaw AI agent framework:

Best Practices

1. Use Ephemeral VMs for Untrusted Code

2. Set Resource Limits

3. Use Timeouts on All Commands

4. Inject Secrets Securely

5. Monitor Network Access

VMs have full internet access by default through NAT. Monitor or restrict access at the host firewall level if needed.

Error Handling for Agents

Multi-tenant Agent Systems

Run multiple isolated agent workspaces:

Next Steps

Basic Usage

Learn fundamental SmolVM operations

Custom Images

Build specialized images for your agents

Environment Variables

Configure agent environments dynamically

Port Forwarding

Expose agent services to your host