pydantic/monty

A minimal, secure Python interpreter written in Rust for use by AI

View on GitHub ↗Jump to charts ↓Open shareable report

Summary Information

Updated 49 minutes ago
Added to GitGenius on February 16th, 2026
Created on May 28th, 2023
Open Issues & Pull Requests: 116 (-1)
Number of forks: 410
Total Stargazers: 8,097 (+0)
Total Subscribers: 39 (+0)

Repository Insights (GitGenius)

Median issue/PR response: 16.6 hours
Mean response time: 11.3 days
90th percentile: 27.1 days
Tracked items: 132

How this project is maintained

Around half of the issues opened in the past year never receive a reply. 74% of open issues come from outside the core team, so the backlog reflects real-world use rather than internal planning. 36% of tracked open issues have had no activity in three months. Only 13% of issues opened in the past year have been closed. Three people close 89% of everything that gets resolved.

Charts & Analytics

Fetching additional details & charts...

Issue Activity (beta)

Open issues: 73
New in 7 days: 1
Closed in 7 days: 2
Avg open age: 13 days
Stale 30+ days: 44
Stale 90+ days: 26

Recent activity

Opened in 7 days: 1
Closed in 7 days: 1
Comments in 7 days: 3
Events in 7 days: 8

Top labels

  • bug (11)
  • security (8)

Detailed Description

Monty is a minimal Python interpreter written in Rust designed specifically for safely executing code generated by large language models and AI agents. The project addresses a critical need in AI systems where LLMs can express their intentions through Python code rather than traditional tool calling, enabling faster and more reliable agent execution without the overhead and complexity of containerized sandboxes.

The interpreter prioritizes security and performance as its core design principles. It completely blocks access to the host environment by implementing filesystem, environment variable, and network access through external function calls that developers can control. This means untrusted code cannot escape the sandbox or access sensitive system resources. Monty supports a reasonable subset of Python functionality including type hints with full modern Python typing support, async and sync code execution, and a limited standard library covering sys, os, typing, asyncio, re, datetime, json, and dataclasses. The interpreter can call functions on the host but only those explicitly granted access by the developer.

Performance is a defining characteristic of Monty. It achieves startup times measured in single-digit microseconds rather than the hundreds of milliseconds required by container-based approaches, making it practical for high-frequency code execution in agent loops. Runtime performance is generally comparable to CPython, typically between five times faster and five times slower depending on the workload. The interpreter can be snapshotted to bytes at external function call boundaries, allowing developers to store interpreter state in files or databases and resume execution later, enabling sophisticated execution patterns like pause-and-resume workflows.

The project is implemented in Rust with no dependencies on CPython, making it callable from Rust, Python, or JavaScript. The Python package is distributed via PyPI as pydantic-monty and executes code in a pool of worker subprocesses, ensuring that even adversarial code causing memory errors or stack overflows cannot crash the host process. JavaScript bindings are available as native NAPI bindings for Node.js and as WebAssembly for browser environments. Monty also provides resource control capabilities, tracking memory usage, allocations, stack depth, and execution time with the ability to cancel execution if preset limits are exceeded.

The repository overlaps with major projects including microsoft/vscode, python/cpython, and rust-lang/rust through shared contributors.

Monty explicitly cannot support the full Python standard library, third-party libraries like Pydantic, class definitions yet, or match statements, though class support is planned. The project is intentionally limited and designed for one specific use case: running code written by agents. The README notes the project is experimental and still in development. Monty will power code-mode functionality in Pydantic AI, allowing LLMs to write Python code that calls tools as functions rather than making sequential tool calls. Community bindings exist for Go and Dart/Flutter, extending the interpreter's accessibility beyond its native language support.