Running Pydantic's Monty Rust sandboxed Python subset in WebAssembly

AI-generated summary of reporting by Simon Willison’s Weblog. Read the original for the full story.

Why it matters

Developers running LLM-generated Python can now sandbox it in microseconds via Pydantic's Monty, compiled to WebAssembly to run in browsers.

Read this as

Simon Willison tried Pydantic's new tool called Monty, a small version of the Python programming language built for safely running code written by AI assistants. Normally this needs a slow virtual container; Monty starts in microseconds and blocks access to files and the network. It does not even support class definitions yet. Willison used an AI tool, Claude Code, to compile it into WebAssembly so it runs in a web browser.

Pydantic released Monty, a sandboxed Python subset in Rust for executing AI-generated code without container overhead, with startup in single-digit microseconds versus hundreds of milliseconds. Willison demonstrated it compiled to WebAssembly in two forms, with working browser demos. Teams building coding agents gain a fast, small alternative to container sandboxes; it is early, version 0.0.3, and lacks features like class declarations.

Monty is a Rust implementation of a Python subset from Pydantic, shipped as both a Rust library and Python package (pydantic-monty, tested at 0.0.3), blocking filesystem, environment and network access except via developer-controlled external calls. Willison compiled it to WebAssembly as a standalone .wasm bundle callable from JavaScript and as a CPython 3.13/emscripten wheel loadable in Pyodide, with two GitHub Pages demos. Execution was measured at 4.0ms in the browser. Class declarations are unsupported; agents are expected to adapt from error messages.

Read the original

This summary exists to save you time, not to replace the source.

Key terms

Monty Pydantic WebAssembly Pyodide Claude Code Simon Willison

Was this summary useful?

One click, anonymous. It tells us which summaries to re-run.

Related reading