llm_query(). This environment is production-ready and essential for executing untrusted LM-generated code or handling sensitive data.
Prerequisites
Arguments
| Argument | Type | Default | Description |
|---|---|---|---|
app_name | str | "rlm-sandbox" | Modal app name |
timeout | int | 600 | Sandbox timeout in seconds |
image | modal.Image | Auto | Custom Modal image |
setup_code | str | None | Code to run at initialization |
context_payload | str | dict | list | Auto | Initial context (set by RLM) |
lm_handler_address | tuple | Auto | Socket address (set by RLM) |
How It Works
Modal sandboxes can’t connect directly to the host. Uses HTTP broker pattern:- Sandbox starts Flask broker server on port 8080
- Port exposed via Modal’s
encrypted_portstunnel llm_query()POSTs to local broker, blocks waiting- Host polls
{tunnel}/pendingevery 100ms - Host forwards requests to LM Handler, POSTs responses back
- Broker unblocks and returns response
Custom Image
You can use your own custom Modal images or update the given image:Default Image
Includes:numpy, pandas, scipy, sympy, requests, httpx, flask, pyyaml, tqdm, dill