pydantic-monty investigation

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

Why it matters

Developers running untrusted AI-generated Python get a sandboxed interpreter whose resource limits (max_duration_secs, max_memory, max_allocations, max_recursion_depth) actually work, verified hands-on.

Read this as

Simon Willison reviewed pydantic-monty, a small, fast way to run Python code inside a locked box. It only supports a limited subset of Python, and when something isn't supported it returns a clear error instead of breaking the host application. Willison had the Claude Code AI tool examine the latest release and confirmed the safety limits work as promised. This matters for anyone letting AI-generated code run inside their software.

Willison's review of pydantic-monty, the Rust-implemented sandboxed Python subset from the Pydantic ecosystem, confirms its key risk controls, time, memory, allocation and recursion caps, perform as advertised. For teams executing AI-generated code, this means a viable sandboxing option with clean failure modes. The article is a short opinionated review, not a benchmark study, and includes no performance numbers.

Monty is a minimal Python interpreter written in Rust for controlled sandboxed execution, omitting most of CPython's functionality. Unsupported features and missing resources fail as structured errors rather than leaking into the host runtime; it is aimed at data transformation, branching, looping and calls to a small set of trusted host tools or a virtual filesystem. Willison verified max_duration_secs, max_memory, max_allocations and max_recursion_depth all work as documented, using Claude Code on the latest release.

Read the original

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

Key terms

pydantic-monty Monty Simon Willison Claude Code CPython Datasette Pyodide

Was this summary useful?

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

Related reading

datasette-charts 0.5a0

Datasette Charts 0.5a0 adds calendar heatmaps, box plots and active-over-time charts, enabling richer data visualisation directly in the browser without extra libraries.