Monty is a Python interpreter written in Rust for running code that a language model writes, without a container, virtual machine, or remote sandboxing service in the loop. Filesystem, environment variables, and network access do not exist inside the sandbox: code reaches the host only through the functions and mounts the application passes in, and the host function runs outside while the sandbox sees only its return value.
Sandboxes are checked out from a pool of worker subprocesses, and a session persists between commands, so a REPL-style agent does not re-run earlier code. Memory, time, and recursion limits are enforced by the interpreter itself. The whole sandbox state can be dumped to bytes at an external function call or at the end of a snippet and resumed later, which supports long-running external calls and human-in-the-loop pauses.
| Sandbox | New sandbox | 10-command agent run | Combined |
|---|---|---|---|
| OSS Monty (local) | 0.80 ms | 0.40 ms | 1.20 ms |
| Full Monty (remote, WebSocket) | 1.70 ms | 5.30 ms | 7.00 ms |
| WASI / wasmtime | 16 ms | 180 ms | 200 ms |
| Local Docker | 195 ms | 700 ms | 900 ms |
| Sandboxing service | 1500 ms | 400 ms | 1900 ms |
| Pyodide in Deno | 2700 ms | 35 ms | 2700 ms |
Monty comes as an open-source package for Python, JavaScript and TypeScript, and Rust, and as Full Monty, a commercial server that runs the same sandbox remotely behind a WebSocket. It powers Code Mode in Pydantic AI, and community bindings exist for Go and Dart.
Features
- No host access by default: no filesystem, environment variables, or network inside the sandbox, only functions and mounts the host provides
- Pooled sandboxes: a new sandbox is a checkout from a worker pool in under 1 ms
- Persistent sessions: REPL state carries across commands so earlier code is not re-run
- Suspend and resume: serialize the full interpreter state to bytes and resume it later
- Resource limits: memory, time, and recursion limits enforced by the interpreter
- Language bindings: Python, JavaScript and TypeScript, and Rust packages, plus community Go and Dart bindings
- Full Monty server: a commercial WebSocket service that runs the same sandbox remotely
- Code Mode: used as the execution engine for Code Mode in Pydantic AI
