LLM Sandbox

Normal
GitHub Python MIT

Description

Lightweight and portable LLM sandbox runtime Python library — provides a code interpreter for safely executing AI agent-generated code in isolated environments.

Key Features

  • Secure Isolated Execution: Code runs in isolated containers with no host system access, supports custom security policies and resource limits
  • Multiple Container Backends: Supports Docker, Kubernetes, and Podman container backends for different deployment environments
  • Multi-Language Support: Supports Python, JavaScript/Node.js, Java, C++, Go, R with automatic dependency management
  • LLM Framework Integration: Seamless integration with LangChain, LangGraph, LlamaIndex, OpenAI and other major frameworks
  • MCP Protocol Support: Runs as an MCP server, allowing clients like Claude Desktop to execute code in the sandbox
  • Advanced Features: Supports chart capture, dynamic library installation, file operations, container pooling, and interactive sessions

Use Cases

💡 AI Agent Secure Execution: Provide secure execution environment for LLM-generated code, preventing malicious code from affecting the host
💡 Online Code Evaluation: Build secure online programming evaluation systems with multi-language code execution and result capture
💡 Data Analysis Visualization: Execute Python data analysis code in isolated environments, securely capture generated charts
💡 Teaching Demo Platform: Provide secure online code execution environments for programming education with interactive learning support

Quick Start

1. Install: pip install 'llm-sandbox[docker]'
2. Basic usage: from llm_sandbox import SandboxSession
3. Create session and run code: with SandboxSession(lang="python") as session: result = session.run("print('Hello')")
4. Install libraries: session.run(code, libraries=["numpy"])

Related Projects

Related Articles