Podcasts
Latent Space — ⚡️Monty: the ultrafast Python interpreter by Agents for Agents — Samuel Colvin, Pydantic
Key takeaway: Pydantic founder Samuel Colvin wrote Monty, an ultralight Python interpreter in Rust over the Christmas holidays, specifically addressing secure isolation and extremely low latency when AI agents call tools through code.
Samuel Colvin founded Pydantic, a widely used data-validation library in Python. Its commercial product, Logfire, is an AI-native observability platform competing with Braintrust, Langsmith, and Langfuse, with full OpenTelemetry logs, metrics, and traces. Logfire differentiates itself by letting users run arbitrary SQL queries on their data, giving AI connected through an MCP server powerful exploration capabilities with almost no additional development.
Monty emerged from an unexpected convergence. In separate conversations with four Anthropic employees, each independently said type safety was crucial for chained tool calling, making Samuel realize Anthropic was exploring something internally. Soon afterward, Anthropic released programmatic tool calling and code-mode capabilities, while Cloudflare also promoted code mode. An investor focused on sandboxes estimated that 70% of sandbox calls are effectively tool calling or embellished tool calling, such as rendering charts or calculations. These do not require full computer-use capabilities but become highly expressive through code.
Monty sits between simple tool calling and a full sandbox. Simple tool calling is safe and lightweight but limited in expression; full sandboxes such as Modal, E2B, and Daytona are powerful but require external infrastructure, making them nearly impossible for enterprises such as large financial institutions unable to use cloud sandboxes. Monty is a single Rust binary installed through pip or npm and runs in the same process. Code execution in a hot loop takes as little as 800 nanoseconds, cold starts take single-digit microseconds, and by comparison a Daytona sandbox starts in around 1 second.
Monty offers very granular security controls. All external function calls pass through the host program, letting developers restrict accessible domains, execution time, and memory precisely. Samuel gave an example: a fully automated web-crawling agent built with Monty and Playwright to gather model pricing from AI companies’ official sites. The full run took 102 seconds, cost 30 cents, and successfully extracted prices. He added that asking an LLM to return both the result and “the optimal Python code for doing this task next time,” then passing that code directly into the next run, can make it succeed on its first attempt and greatly reduce exploration costs.
On differences from CPython, Samuel candidly acknowledged that Monty is not full CPython: third-party libraries such as Pydantic and NumPy cannot be installed, classes cannot be defined internally, match statements are not yet supported, and only parts of the standard library are implemented. He believes this suffices for most agent scenarios because external functions, such as network requests and Pydantic validation, can be registered as host functions, executed outside, and return results to Monty. A built-in type checker requires LLM-generated code to pass type checking before execution, greatly reducing runtime errors.
Samuel shared lessons from AI-assisted Monty development. When a task meets four conditions, he believes LLMs improve efficiency not 3-5 times but 100 times: the internal implementation is familiar to the model, such as a bytecode interpreter; the external API is also familiar, with Python semantics already internalized; unit testing is trivial, requiring only comparison of CPython and Monty outputs; and interface design needs no discussion because Python’s behavior is already defined. Under these conditions, he wrote 30000 lines of Rust with AI over Christmas, feeling that “the world has truly gone crazy.”
His daily workflow mixes Claude Code, Codex, and Gemini CLI. He compares them to superheroes: Claude Code is Captain America, capable, confident, and sometimes overconfident; Codex is Q from the Bond films, neurotic, precise, and focused on small details; Gemini is the Joker, occasionally brilliant but deleting your files half the time. He usually gives Gemini only code review work, without write permissions, and hands its report to Claude Code for implementation. He sees Gemini’s strength in technical depth, believing Google’s huge private codebase has influenced its weights, sometimes producing surprises on low-level work such as bytecode interpreters.
On commercialization, Samuel admits Monty’s biggest problem is how to make money. Its central value is eliminating hosted services, making a SaaS version somewhat contradictory. He sees a larger opportunity with Logfire: continuous agent self-optimization built on Pydantic AI, improving prompts, model choices, and code logic as execution data accumulates, either fully automatically or with human approval. He also mentioned forthcoming serializable agents in Pydantic AI, allowing all configuration—model, system prompt, code mode, MCP servers, and more—to be defined in one TOML file, laying the foundation for reuse across environments and automatic optimization.