Secure Python Runtime / AI Agent Execution Environment
6.9k 2026-04-18
pydantic/monty
A minimal, secure, and high-performance Python interpreter written in Rust, designed for safely executing LLM-generated code within AI agents without container overhead.
Core Features
Secure sandboxed execution with controlled host access
Extremely fast startup (<1μs) and efficient runtime performance
Supports a reasonable subset of Python with modern type hints
Ability to snapshot interpreter state and control resource usage
Callable from Rust, Python, or Javascript without CPython dependencies
Quick Start
pip install pydantic-montyDetailed Introduction
Monty is an experimental, Rust-based Python interpreter specifically engineered for AI agents to safely execute LLM-generated code. It bypasses the overhead and complexity of traditional container-based sandboxes, offering microsecond-level startup times and robust security features. Developers can control host environment access, define callable host functions, and manage resources, making it ideal for integrating Python code execution directly into AI workflows with minimal latency and maximum safety. It aims to enable more reliable and cost-effective agent operations.