Pydantic AI has announced "Monty," a lightweight interpreter for the secure execution of Python code generated by LLMs. Implemented in Rust, it features faster startup times compared to container-based sandboxes.
Pydantic AI Releases Monty, a Rust-based Python Interpreter for Executing LLM-Generated Code
This article is a translation. Read the Japanese original
Conventional methods for executing LLM-generated code involve the overhead and complexity of launching containers. Monty avoids this, achieving startup times in the single-digit microsecond range. The goal is to improve processing efficiency and reliability by having LLMs write code rather than relying solely on tool calls.
The runtime consists of a process pool of monty workers. Even if adversarial code causes memory errors or stack overflows, the host process does not crash. Instead, the worker process terminates, triggers a MontyCrashedError, and is replaced by a new process.
The interpreter targets Python 3.14 and can be called from Python, JavaScript/TypeScript, and Rust. It can be installed via uv add pydantic-monty or npm install @pydantic/monty. It is currently in an experimental stage and serves as the underlying technology supporting Pydantic AI's Code Mode.
Source: Monty: A minimal, secure Python interpreter written in Rust for use by AI(HN 323pt・164コメント)(HN Search (backfill), 2026-02-07)