Skip to main content
This guide will walk you through the basics of using Monty to execute Python code safely in your applications.

Choose Your Language

Basic Expression Evaluation

Start by running a simple Python expression:

Using Input Variables

Pass variables to your code:

External Functions

Call host functions from your sandboxed code:

Iterative Execution

For fine-grained control over external function calls:

Async External Functions

Use async/await with external functions:

Resource Limits

Control resource usage to prevent runaway execution:

Key Concepts

Inputs

Variables you want to pass into the sandboxed code. Declare them when creating the interpreter.

External Functions

Host functions that sandboxed code can call. These are the only way for Monty code to interact with the outside world.

Resource Limits

Control execution time, memory usage, and allocations to prevent runaway code.

Snapshots

Pause execution at external function calls and resume later, even across process boundaries.

Common Patterns

Agent Workflow Example

Here’s a real-world example of using Monty for an agent workflow:

Next Steps

Core Concepts

Learn more about Monty’s core features

External Functions

Deep dive into external function handling

Resource Limits

Configure resource limits for safety

Type Checking

Use static type checking with your code