LLM Sandbox
Python library that runs model-generated code through one API on Docker, Podman or Kubernetes, with Bubblewrap/nsjail local backends and an MCP server. A convenient backend-agnostic wrapper for teams that already run containers and want a Python-first code-execution layer.
Overview
LLM Sandbox "runs Large Language Model (LLM) generated code through a common API" over several backends: Docker, Podman and Kubernetes containers, and on Linux the Bubblewrap and NsJail OS sandboxes (which the README is explicit share the host kernel). It supports Python, JavaScript/Node.js, Java, C++, Go and R, extracts plots as artifacts, pools containers, keeps interactive Python sessions, and ships an MCP server so clients such as Claude Desktop can execute code in it. Examples cover eleven agent frameworks including LangChain and LlamaIndex.
It is a library rather than a service, so limits, lifetime and persistence are whatever the backend gives you. Security policies are advisory: is_safe() reports a verdict but does not stop run(). The Windows adapters are labelled "experimental adapters with different prerequisites and API limits". MIT-licensed; pip install llm-sandbox with extras per backend.
Notable
- Backends: Docker, Podman, Kubernetes, Bubblewrap and NsJail (Linux), plus experimental Windows MXC and WSL2 adapters
- Six languages (Python, JavaScript, Java, C++, Go, R) and an MCP server
- README: "Security policies are advisory"
LLM Sandbox specifications
| Attribute | Details |
|---|---|
| Isolation | Container per session on Docker, Podman or Kubernetes; optional Bubblewrap or NsJail backends on Linux that share the host kernel and are "not a VM boundary"; experimental Windows adapters (Windows MXC, WSL2 Bubblewrap) |
| Deployment | Open-source project · Self-hostable |
| Open source | Yes (MIT) |
| SDKs and interfaces | Python, MCP server |
| Cold start (vendor claim) | Not documented |
| Max session length | Not documented |
| Persistence | Interactive Python sessions keep state between runs; container pooling for reuse; file copy to and from the sandbox; artifact extraction of plots. Local Linux backends do not support images, pooling or interactive sessions |
| GPU | Not documented |
| Networking | Network isolation and resource limits (CPU, memory, time) per session; security policies are advisory (is_safe() returns a verdict without blocking run()) |
| Pricing | Free (MIT) |
| Free tier | Free to self-host |
| Compliance | Not documented |
| Regions | Not documented |
Facts from LLM Sandbox’s public documentation, verified November 9, 2026. Performance numbers are vendor claims.
Strengths and trade-offs
Strengths
- You want one Python API over Docker, Podman and Kubernetes
- You need plots and files extracted from the sandbox for data-analysis agents
- You run a desktop MCP client and want it to execute code in a container
Trade-offs
- Isolation is only as strong as the container runtime; local Linux backends share the host kernel
- Security policies do not block execution on their own
- No documented startup figures, GPU support or hosted option
Good fit for: Python applications that need to run model-generated code in whatever container runtime they already have.
How LLM Sandbox compares
| Sandbox | Isolation | Open source | Self-host / BYOC | Cold start (vendor) | Max session | Snapshots / pause | GPU | SDKs |
|---|---|---|---|---|---|---|---|---|
| LLM Sandbox | Docker/Podman/K8s container | Yes | Yes / No | Not documented | Not documented | No / Not documented | Not documented | Python, MCP server |
| SWE-ReX | Docker / Modal / Fargate | Yes | Yes / No | Not documented | Not documented | No / Not documented | Not documented | Python, REST API |
| OpenHands Runtime | Docker container | Yes | Yes / No | Not documented | Not documented | Not documented / Not documented | Not documented | Python, JavaScript/TypeScript, REST API |
| Docker Sandboxes | MicroVM | No | Yes / No | Not documented | Until removed (local) | Yes / Yes | Yes | sbx CLI, TypeScript (cloud), REST API (cloud) |
| Judge0 | isolate (namespaces/cgroups) | Yes | Yes / No | Not documented | 5 s wall (max 20 s) | No / No | No | REST API, Python, JavaScript/TypeScript |
| bubblewrap | Linux namespaces | Yes | Yes / No | Not documented | Not documented | No / No | Not documented | CLI |
Frequently asked questions
What is LLM Sandbox?
How does LLM Sandbox isolate code?
Is LLM Sandbox open source?
How much does LLM Sandbox cost?
What are the alternatives to LLM Sandbox?
Sources
Cite this page
Agent Sandboxes. (2026). LLM Sandbox. agentsandboxes.org. Last reviewed November 9, 2026. https://agentsandboxes.org/sandboxes/llm-sandbox/
Found an error or a missing sandbox? Submit a correction — every entry links to the sources it relies on.