A runtime that executes untrusted code for AI agents inside isolated WebAssembly sandboxes, with CPU, memory and timeout limits per task.
vndee/llm-sandbox
Python library that runs LLM-generated code in isolated sandboxes through one API across Docker, Kubernetes, Podman and local Linux or Windows backends.
- Stars
- 1,144
- Forks
- 106
- Open issues
- 25
- Last commit
- yesterday
What is it?
LLM Sandbox provides a common Python API for executing code produced by language models inside an isolated environment. A developer picks a backend such as Docker, Kubernetes, Podman, Bubblewrap, NsJail, or experimental Windows adapters, configures resource and network controls, and then calls the same run, install and file-copy methods regardless of which backend is in use.
The library supports Python, JavaScript, Java, C++, Go and R, and can install declared libraries before execution. Artifact sessions capture generated plots, and an interactive session keeps a Python IPython kernel alive across calls for notebook-style work. A container pool option pre-warms and reuses containers for repeated executions, and an MCP server lets clients such as Claude Desktop call the sandbox directly.
The project includes examples for eleven agent frameworks, including LangChain, LlamaIndex and CrewAI. Its security policy check is advisory only: it returns a verdict but does not block execution, so callers must check code themselves before running it.
Key features
- 01Common API across Docker, Kubernetes, Podman, Bubblewrap, NsJail and Windows adapters
- 02Configurable CPU, memory, network and execution time limits
- 03Supports Python, JavaScript, Java, C++, Go and R
- 04Installs declared libraries before running code
- 05Captures plots generated by Python and R code
- 06Container pooling to reuse pre-warmed containers
- 07MCP server for clients such as Claude Desktop
Use cases
- Running code written by an LLM agent before returning results to the user
- Adding a code interpreter tool to LangChain, CrewAI or similar agent frameworks
- Executing untrusted scripts on a local Linux host without Docker
- Letting a chat assistant generate and display plots safely
Quick start
- 1
Install the package from PyPI
pip install llm-sandbox - 2
Install the Docker extra for the most common backend
pip install 'llm-sandbox[docker]' - 3
Run the basic Python example from the README with a SandboxSession
Things to know
- Local Linux backends share the host kernel and are not a VM boundary.
- Windows adapters are experimental, with limited language support and API features.
- Container backends such as Docker, Kubernetes and Podman need a running container runtime.
In collections
Topics
FAQ
- What is llm-sandbox?
- Python library that runs LLM-generated code in isolated sandboxes through one API across Docker, Kubernetes, Podman and local Linux or Windows backends. LLM Sandbox provides a common Python API for executing code produced by language models inside an isolated environment. A developer picks a backend such as Docker, Kubernetes, Podman, Bubblewrap, NsJail, or experimental Windows adapters, configures resource and network controls, and then calls the same run, install and file-copy methods regardless of which backend is in use.
- Is llm-sandbox free to use? What license does it have?
- llm-sandbox is open source under the MIT license. Check the license terms before using it in commercial products.
- Is llm-sandbox still maintained?
- Actively maintained. The last commit to llm-sandbox was on Nov 6, 2026.
- What can I use llm-sandbox for?
- Running code written by an LLM agent before returning results to the user Adding a code interpreter tool to LangChain, CrewAI or similar agent frameworks Executing untrusted scripts on a local Linux host without Docker Letting a chat assistant generate and display plots safely
- How do I install llm-sandbox?
- Install the package from PyPI: pip install llm-sandbox Install the Docker extra for the most common backend: pip install 'llm-sandbox[docker]' Run the basic Python example from the README with a SandboxSession
- Where can I get llm-sandbox?
- The source code and installation instructions are on GitHub: https://github.com/vndee/llm-sandbox
Summary generated by AI from the project's README. GitHub stats refresh daily.
Related projects
A Python library and REST API that runs LLM-generated Python code in an isolated Docker container with resource limits, timeouts, and safety checks.
Open-source sandbox service for AI agents that runs each workload in a hardware-isolated MicroVM, with E2B SDK compatibility and sub-60ms startup.
A sandbox platform that runs agent and user code in isolated Firecracker microVMs, controlled through an HTTP API.
Self-hosted Kubernetes-based infrastructure that runs untrusted code in lightweight VM sandboxes, controlled via a CLI, HTTP API and Python SDK.
Open-source sandbox runtime that gives AI agents isolated environments to run code, commands, files, and browsers on your own infrastructure.