Repolode
pydantic

pydantic/monty

A secure Python sandbox written in Rust for running code generated by AI, without containers.

Stars
8,730
Forks
465
Open issues
169
Last commit
15 hours ago

What is it?

Monty is a Python sandbox for executing LLM-generated code. It aims to avoid the latency, complexity and cost of container-based sandboxes, with a new sandbox taking under 1ms from a running pool according to the project's measurements.

Inside the sandbox there is no filesystem, environment variable or network access. Code reaches the host only through functions and mounts that the host application explicitly passes in. In the example, a host-side lookup function returns nutritional data while the sandboxed code sees only its return value.

OSS Monty is MIT licensed and installable as a package for Python (pydantic-monty), JavaScript/TypeScript (@pydantic/monty) and Rust (monty). A commercial Full Monty server runs the same sandbox behind a WebSocket as a service.

Key features

  • 01Runs Python code in a sandbox with no filesystem, environment or network access by default.
  • 02Exposes host functions and mounts as the only way for code to reach outside resources.
  • 03Provides bindings for Python, JavaScript/TypeScript and Rust.
  • 04Supports resource limits and execution snapshots.
  • 05Reuses a pool of sandboxes to keep startup latency low.

Use cases

  • Executing code written by an LLM agent without spinning up a container per run.
  • Letting AI agents call host-side tools through a controlled function interface.
  • Adding a safe code-execution step to a Python, JavaScript or Rust application.

Quick start

  1. 1

    Install the Python package

    uv add pydantic-monty
  2. 2

    Create a sandbox pool and session, then run code

Things to know

  • Sandbox runs Python 3.14 only, a subset of the full language per the docs.
  • Filesystem, environment variables and network are unavailable inside the sandbox; host access is only through functions you pass in.
  • Full Monty, the commercial server edition, is separate from this MIT-licensed OSS version.

Topics

FAQ

What is monty?
A secure Python sandbox written in Rust for running code generated by AI, without containers. Monty is a Python sandbox for executing LLM-generated code. It aims to avoid the latency, complexity and cost of container-based sandboxes, with a new sandbox taking under 1ms from a running pool according to the project's measurements.
Is monty free to use? What license does it have?
monty is open source under the MIT license. Check the license terms before using it in commercial products.
Is monty still maintained?
Actively maintained. The last commit to monty was on Oct 19, 2026.
What can I use monty for?
Executing code written by an LLM agent without spinning up a container per run. Letting AI agents call host-side tools through a controlled function interface. Adding a safe code-execution step to a Python, JavaScript or Rust application.
How do I install monty?
Install the Python package: uv add pydantic-monty Create a sandbox pool and session, then run code
Where can I get monty?
The source code and installation instructions are on GitHub: https://github.com/pydantic/monty

Summary generated by AI from the project's README. GitHub stats refresh daily.

Related projects