Skip to content
Open
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 11 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -77,18 +77,27 @@ make quickstart
</details>

## REPL Environments
We support two types of REPL environments -- isolated, and non-isolated. Non-isolated environments (default) run code execution on the same machine as the RLM (e.g. through `exec`), which is pretty reasonable for some local low-risk tasks, like simple benchmarking, but can be problematic if the prompts or tool calls can interact with malicious users. Fully isolated environments used Cloud-based sandboxes (e.g. Prime Sandboxes, [Modal Sandboxes](https://modal.com/docs/guide/sandboxes)) to run code generated by the RLM, ensuring completely isolation from the host process. Environments can be added, but we natively support the following: `local` (default), `modal`, `prime`.
We support two types of REPL environments -- isolated, and non-isolated. Non-isolated environments (default) run code execution on the same machine as the RLM (e.g. through `exec`), which is pretty reasonable for some local low-risk tasks, like simple benchmarking, but can be problematic if the prompts or tool calls can interact with malicious users. Fully isolated environments use Cloud-based sandboxes (e.g. Prime Sandboxes, [Modal Sandboxes](https://modal.com/docs/guide/sandboxes)) to run code generated by the RLM, ensuring complete isolation from the host process. Environments can be added, but we natively support the following: `local` (default), `monty`, `modal`, `prime`.

```python
rlm = RLM(
environment="...", # "local", "docker", "modal", "prime"
environment="...", # "local", "monty", "docker", "modal", "prime"
environment_kwargs={...},
)
```

### Local Environments
The default `local` environment `LocalREPL` runs in the same process as the RLM itself, with specified global and local namespaces for minimal security. Using this REPL is generally safe, but should not be used for production settings. It also shares the same virtual environment (e.g. Conda or uv) as the host process.

#### Monty
We also support a Monty-based environment called `MontyREPL` that runs code inside the Monty sandboxed interpreter. Monty is fast and sandboxed, but it supports only a limited subset of Python and a small standard library. Monty also supports `persistent=True` for multi-turn mode (state retained via host-side locals).

To install Monty support:
```bash
uv pip install -e ".[monty]"
# or: pip install pydantic-monty
```

#### Docker <img src="https://github.com/docker.png" alt="Docker" height="20" style="vertical-align: middle;"/> (*requires [Docker installed](https://docs.docker.com/desktop/setup/install/)*)
We also support a Docker-based environment called `DockerREPL` that launches the REPL environment as a Docker image. By default, we use the `python:3.11-slim` image, but the user can specify custom images as well.

Expand Down
1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ Issues = "https://github.com/alexzhang13/rlm/issues"
modal = ["modal>=0.73.0", "dill>=0.3.7"]
daytona = ["daytona>=0.128.1", "dill>=0.3.7"]
prime = ["prime-sandboxes>=0.2.0", "dill>=0.3.7"]
monty = ["pydantic-monty>=0.0.4"]

[build-system]
requires = ["setuptools>=61.0"]
Expand Down
2 changes: 1 addition & 1 deletion rlm/core/rlm.py
Original file line number Diff line number Diff line change
Expand Up @@ -369,7 +369,7 @@ def _validate_persistent_environment_support(self) -> None:
ValueError: If the environment type does not support persistent mode.
"""
# Known environments that support persistence
persistent_supported_environments = {"local"}
persistent_supported_environments = {"local", "monty"}

if self.environment_type not in persistent_supported_environments:
raise ValueError(
Expand Down
2 changes: 1 addition & 1 deletion rlm/core/types.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
"azure_openai",
"gemini",
]
EnvironmentType = Literal["local", "docker", "modal", "prime", "daytona"]
EnvironmentType = Literal["local", "docker", "modal", "prime", "daytona", "monty"]


def _serialize_value(value: Any) -> Any:
Expand Down
11 changes: 8 additions & 3 deletions rlm/environments/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,12 @@


def get_environment(
environment: Literal["local", "modal", "docker", "daytona", "prime"],
environment: Literal["local", "modal", "docker", "daytona", "prime", "monty"],
environment_kwargs: dict[str, Any],
) -> BaseEnv:
"""
Routes a specific environment and the args (as a dict) to the appropriate environment if supported.
Currently supported environments: ['local', 'modal', 'docker', 'daytona', 'prime']
Currently supported environments: ['local', 'modal', 'docker', 'daytona', 'prime', 'monty']
"""
if environment == "local":
return LocalREPL(**environment_kwargs)
Expand All @@ -32,7 +32,12 @@ def get_environment(
from rlm.environments.prime_repl import PrimeREPL

return PrimeREPL(**environment_kwargs)
elif environment == "monty":
from rlm.environments.monty_repl import MontyREPL

return MontyREPL(**environment_kwargs)
else:
raise ValueError(
f"Unknown environment: {environment}. Supported: ['local', 'modal', 'docker', 'daytona', 'prime']"
f"Unknown environment: {environment}. Supported: "
"['local', 'modal', 'docker', 'daytona', 'prime', 'monty']"
)
Loading
Loading