# Modal simulator

A local Modal for agent tests: apps, functions and sandboxes over the Python SDK's gRPC API, with your code run as local processes.

`modal-twin` is a local, stateful simulator of Modal for testing code that calls Modal through its Python SDK. It serves the SDK's gRPC API on one port: apps and sandboxes that run commands and hold files. It also serves functions, called with `.remote()`, `.spawn()` and `.map()`. Your functions and sandbox commands run for real, as local processes on the simulator's machine. Expect Modal's own results and SDK exceptions everywhere except where a **Differs from Modal** line or [Limitations](#limitations) names a gap. It never calls Modal, builds no image and has no GPU, so no test app reaches a real workspace.

## Quickstart

<!-- BEGIN generated: quickstart (go run ./ingest/cmd/twindocs modal; do not edit) -->

Install the CLI, sign in and boot the simulator with `RYSTIC_URL` pointing at it.

On Pro you sign in with an API key from [your account](https://www.rystic.ai/account/api-keys).

```bash
curl -fsSL https://www.rystic.ai/install.sh | sh
rystic login rys_…   # your API key
export RYSTIC_URL=$(rystic run modal-twin -d --port 0 --scenario modal_app_states --json | jq -r .data.url)
curl -s "$RYSTIC_URL/_rystic/version"
# -> {..."product":"modal-twin"...}
```

On Enterprise, the licensed edition signs in with a license file in place of the key: `rystic login ./rystic-license.json` ([licensing](https://www.rystic.ai/docs/licensing)).

<!-- END generated: quickstart -->

### First calls

Read the default scenario's deployed app through the control plane, then look it up and create an app through the SDK. Your code reaches the simulator over gRPC, so the calls are Python.

```bash
curl -s "$RYSTIC_URL/_rystic/inspect" | jq -c '.state_app[] | select(.app_state == "APP_STATE_DEPLOYED") | {app_id, name}'
# -> {"app_id":"ap-Life000000000000000004","name":"billing-api"}
```

Save this as `first_calls.py`:

```python
import modal

deployed = modal.App.lookup("billing-api")
print(deployed.app_id)

created = modal.App.lookup("first-calls", create_if_missing=True)
print(created.app_id)
```

Put the `modal` version that [The Python your code runs on](https://www.rystic.ai/docs/simulators/modal/features/python-runtime.md) names in place of `<version>`, run the file and read the new app back:

<!-- example: skip network -->
```bash
pip install -q "modal==<version>"
MODAL_SERVER_URL="$RYSTIC_URL" MODAL_TOKEN_ID=ak-example MODAL_TOKEN_SECRET=as-example python3 first_calls.py
# -> ap-Life000000000000000004
# -> ap-1
curl -s "$RYSTIC_URL/_rystic/inspect" | jq -c '[.state_app[] | select(.name == "first-calls") | {app_id, name}]'
# -> [{"app_id":"ap-1","name":"first-calls"}]
```

[Functions](https://www.rystic.ai/docs/simulators/modal/features/functions.md) calls your own code, and [Sandboxes](https://www.rystic.ai/docs/simulators/modal/features/sandboxes.md) runs commands.

## Connect your client

Point Modal's Python SDK at the simulator with three environment variables. Your code does not change:

```bash
export MODAL_SERVER_URL="$RYSTIC_URL"
export MODAL_TOKEN_ID=ak-example MODAL_TOKEN_SECRET=as-example
```

The SDK must reach the simulator at `localhost` or `127.0.0.1`, which is where `rystic run` and a published Docker port put it.

| The server URL names | What the SDK does |
|---|---|
| `localhost` or `127.0.0.1` | reaches every method the simulator serves |
| another host name or address | `Sandbox.exec` raises `ValueError: Task router URL must be https`, because the SDK sends a sandbox command over plain HTTP only to those two hosts |

To call the simulator from another container, give that container the simulator's network: `docker run --network container:` followed by the simulator container's name, or `network_mode: "service:<name>"` in Compose. `localhost` is then the simulator.

The gateway does not carry Modal's gRPC yet, so interception does not reach this simulator: point the SDK at it on `localhost` with `MODAL_SERVER_URL`, as above.

Any gRPC client reaches the simulator the same way. These send the SDK's opening `ClientHello`, an empty message, with no token, then with an old client version, then a method the simulator does not serve:

```bash
printf '\0\0\0\0\0' > hello.bin
curl -s --http2-prior-knowledge -H 'Content-Type: application/grpc' -H 'TE: trailers' --data-binary @hello.bin -o /dev/null -D - "$RYSTIC_URL/modal.client.ModalClient/ClientHello" | tr -d '\r' | grep grpc-status
# -> grpc-status: 0
curl -s --http2-prior-knowledge -H 'Content-Type: application/grpc' -H 'TE: trailers' -H 'x-modal-client-version: 0.60' --data-binary @hello.bin -o /dev/null -D - "$RYSTIC_URL/modal.client.ModalClient/ClientHello" | tr -d '\r' | grep grpc-status
# -> grpc-status: 0
curl -s --http2-prior-knowledge -H 'Content-Type: application/grpc' -H 'TE: trailers' --data-binary @hello.bin -o /dev/null -D - "$RYSTIC_URL/modal.client.ModalClient/VolumeList" | tr -d '\r' | grep grpc-status
# -> grpc-status: 12
```

Status 0 is `OK` and 12 is `UNIMPLEMENTED`.

Ten apps created in one burst are all accepted. Each request is `AppGetOrCreate` for a new name:

```bash
for i in 0 1 2 3 4 5 6 7 8 9; do printf '\0\0\0\0\011\012\005app-%s\030\001' "$i" | curl -s --http2-prior-knowledge -H 'Content-Type: application/grpc' -H 'TE: trailers' --data-binary @- -o /dev/null -D - "$RYSTIC_URL/modal.client.ModalClient/AppGetOrCreate"; done | tr -d '\r' | grep -c 'grpc-status: 0'
# -> 10
```

The `modal` command line reads the same variables: [Functions](https://www.rystic.ai/docs/simulators/modal/features/functions.md) deploys an app with `modal deploy`, and `modal app list` lists the simulator's apps:

<!-- example: skip network -->
```bash
MODAL_SERVER_URL="$RYSTIC_URL" MODAL_TOKEN_ID=ak-example MODAL_TOKEN_SECRET=as-example modal app list --json | jq -c '.[] | select(.description == "billing-api") | {app_id, state, tasks}'
# -> {"app_id":"ap-Life000000000000000004","state":"deployed","tasks":"0"}
```

[Limitations](#limitations) lists the `modal app` commands that do not work, and notes that `tasks` reads 0 for every app.

<!-- BEGIN generated: known-clients (go run ./ingest/cmd/twindocs modal; do not edit) -->

No client has been checked against this simulator yet.

<!-- END generated: known-clients -->

## Auth

The simulator checks no token: the first raw call in [Connect your client](#connect-your-client) has none and returns `OK`. Set `MODAL_TOKEN_ID` and `MODAL_TOKEN_SECRET` to any text all the same, because with either one unset the SDK stops with `AuthError: Token missing` before it sends a call.

**Differs from Modal:** the simulator accepts a token Modal never issued, and a call that has no token.

Your Rystic key or license is another matter: pass it to the simulator in its environment, not as a file. [The Python your code runs on](https://www.rystic.ai/docs/simulators/modal/features/python-runtime.md) says what your code can read on a plain host.

## API version

The simulator serves the gRPC API of one release of the `modal` package, the one [The Python your code runs on](https://www.rystic.ai/docs/simulators/modal/features/python-runtime.md) names. Install that release where your tests run. A method of that release the simulator does not serve returns the gRPC status `UNIMPLEMENTED`, which the SDK raises as `UnimplementedError`; [Coverage](#coverage) lists what is served.

**Differs from Modal:** the simulator does not check the version the SDK sends. [Connect your client](#connect-your-client) shows both, in its second and third raw calls.

## Errors and limits

### Error format

An error is a gRPC status: its code in `grpc-status` and its text in `grpc-message`. The SDK raises each code as its own exception, `NotFoundError` for `NOT_FOUND` among them, as it does against Modal. An exception your function raises is raised again in the caller, with its type and message. [Functions](https://www.rystic.ai/docs/simulators/modal/features/functions.md) shows both.

### Rate limits

Modal documents these rate limits, among others:

| Limit | Calls it covers | Allowance Modal documents |
|---|---|---|
| Function calls, shared by the workspace | `FunctionMap`, `MapStartOrContinue` and `AttemptStart` | 2,000 calls a second |
| Parametrized function creation | `FunctionBindParams` | a burst of 1,000 calls, refilled at 1 a second |

By default the simulator refuses no call for speed. [`rate_limits: real`](https://www.rystic.ai/docs/network-profiles.md) turns Modal's limits on: in the stack file, at boot (`rystic run --rate-limits real` or `RYSTIC_RATE_LIMITS=real`) or mid-run with `curl -s -X POST "$RYSTIC_URL/_rystic/network" -d '{"rate_limits": "real"}'`. [Rate limits](https://www.rystic.ai/docs/simulators/modal/features/rate-limits.md) shows a call past the creation limit returning `RESOURCE_EXHAUSTED` (code 8) and what a reset does to it.

**Differs from Modal:** by default no call returns `RESOURCE_EXHAUSTED` for speed.

**Differs from Modal:** with the setting on, the simulator applies only the two limits in the table. Modal also limits each function's own calls and caps how many inputs wait in its queues. It counts each input a `Function.map` sends toward the workspace's 2,000, where the simulator counts each call to the methods in the table, however many inputs it sends.

**Differs from Modal:** Modal limits how fast a workspace creates apps. The burst in [Connect your client](#connect-your-client) creates ten apps and none is refused.

The simulator does bound how many commands and sandboxes run at once, and [The Python your code runs on](https://www.rystic.ai/docs/simulators/modal/features/python-runtime.md) gives both bounds and the settings that raise them.

### Pagination

The SDK pages its lists. `Sandbox.list()` asks for the sandboxes created before the last one it read, until a page comes back empty, and [Sandboxes](https://www.rystic.ai/docs/simulators/modal/features/sandboxes.md) lists an app's sandboxes. `Secret.objects.list()`, `Dict.objects.list()` and `Queue.objects.list()` ask for 100 records at a time, and [Dicts and queues](https://www.rystic.ai/docs/simulators/modal/features/dicts-and-queues.md) shows a dict list and a queue list, newest first.

### Idempotency

Not applicable: the gRPC methods the simulator serves take no idempotency key.

## Coverage

Out of scope: volumes, tunnels, image builds and memory snapshots.

On 2026-11-23, the simulator matched Modal on 261 of the 262 tests that compare the two (99.6%), and every one of them gave a verdict.

<!-- BEGIN generated: served-operations (go run ./ingest/cmd/twindocs modal; do not edit) -->

<!-- coverage-claim -->
99 routes, counted from the simulator's route table.

Also served, outside the model: `GET /blobs`, `PUT /blobs`, `POST /modal.client.ModalClient/AppClientDisconnect`, `POST /modal.client.ModalClient/AppCreate`, `POST /modal.client.ModalClient/AppGetByDeploymentName`, `POST /modal.client.ModalClient/AppGetLayout`, `POST /modal.client.ModalClient/AppGetLifecycle`, `POST /modal.client.ModalClient/AppGetLogs`, `POST /modal.client.ModalClient/AppGetOrCreate`, `POST /modal.client.ModalClient/AppHeartbeat`, `POST /modal.client.ModalClient/AppList`, `POST /modal.client.ModalClient/AppPublish`, `POST /modal.client.ModalClient/AppStop`, `POST /modal.client.ModalClient/AttemptAwait`, `POST /modal.client.ModalClient/AttemptRetry`, `POST /modal.client.ModalClient/AttemptStart`, `POST /modal.client.ModalClient/AuthTokenGet`, `POST /modal.client.ModalClient/BlobCreate`, `POST /modal.client.ModalClient/BlobGet`, `POST /modal.client.ModalClient/ClassCreate`, `POST /modal.client.ModalClient/ClassGet`, `POST /modal.client.ModalClient/ClientHello`, `POST /modal.client.ModalClient/DictClear`, `POST /modal.client.ModalClient/DictContains`, `POST /modal.client.ModalClient/DictContents`, `POST /modal.client.ModalClient/DictDelete`, `POST /modal.client.ModalClient/DictGet`, `POST /modal.client.ModalClient/DictGetOrCreate`, `POST /modal.client.ModalClient/DictHeartbeat`, `POST /modal.client.ModalClient/DictLen`, `POST /modal.client.ModalClient/DictList`, `POST /modal.client.ModalClient/DictPop`, `POST /modal.client.ModalClient/DictUpdate`, `POST /modal.client.ModalClient/EnvironmentGetOrCreate`, `POST /modal.client.ModalClient/FunctionBindParams`, `POST /modal.client.ModalClient/FunctionCallCancel`, `POST /modal.client.ModalClient/FunctionCreate`, `POST /modal.client.ModalClient/FunctionGet`, `POST /modal.client.ModalClient/FunctionGetOutputs`, `POST /modal.client.ModalClient/FunctionMap`, `POST /modal.client.ModalClient/FunctionPrecreate`, `POST /modal.client.ModalClient/FunctionPutInputs`, `POST /modal.client.ModalClient/ImageFromId`, `POST /modal.client.ModalClient/ImageGetOrCreate`, `POST /modal.client.ModalClient/ImageJoinStreaming`, `POST /modal.client.ModalClient/MapAwait`, `POST /modal.client.ModalClient/MapCheckInputs`, `POST /modal.client.ModalClient/MapStartOrContinue`, `POST /modal.client.ModalClient/MountBatchedCheckExistence`, `POST /modal.client.ModalClient/MountGetOrCreate`, `POST /modal.client.ModalClient/MountPutFile`, `POST /modal.client.ModalClient/QueueClear`, `POST /modal.client.ModalClient/QueueDelete`, `POST /modal.client.ModalClient/QueueGet`, `POST /modal.client.ModalClient/QueueGetOrCreate`, `POST /modal.client.ModalClient/QueueHeartbeat`, `POST /modal.client.ModalClient/QueueLen`, `POST /modal.client.ModalClient/QueueList`, `POST /modal.client.ModalClient/QueueNextItems`, `POST /modal.client.ModalClient/QueuePut`, `POST /modal.client.ModalClient/SandboxCreate`, `POST /modal.client.ModalClient/SandboxCreateV2`, `POST /modal.client.ModalClient/SandboxGetCommandRouterAccess`, `POST /modal.client.ModalClient/SandboxGetFromName`, `POST /modal.client.ModalClient/SandboxGetFromNameV2`, `POST /modal.client.ModalClient/SandboxGetLogs`, `POST /modal.client.ModalClient/SandboxGetTaskId`, `POST /modal.client.ModalClient/SandboxGetTaskIdV2`, `POST /modal.client.ModalClient/SandboxList`, `POST /modal.client.ModalClient/SandboxListV2`, `POST /modal.client.ModalClient/SandboxSnapshotFs`, `POST /modal.client.ModalClient/SandboxStdinWrite`, `POST /modal.client.ModalClient/SandboxTagsGet`, `POST /modal.client.ModalClient/SandboxTagsGetV2`, `POST /modal.client.ModalClient/SandboxTagsSet`, `POST /modal.client.ModalClient/SandboxTagsSetV2`, `POST /modal.client.ModalClient/SandboxTerminate`, `POST /modal.client.ModalClient/SandboxTerminateV2`, `POST /modal.client.ModalClient/SandboxWait`, `POST /modal.client.ModalClient/SandboxWaitV2`, `POST /modal.client.ModalClient/SecretDelete`, `POST /modal.client.ModalClient/SecretGetOrCreate`, `POST /modal.client.ModalClient/SecretList`, `POST /modal.client.ModalClient/SecretUpdate`, `POST /modal.client.ModalClient/TaskGetCommandRouterAccess`, `POST /modal.client.ModalClient/TaskList`, `POST /modal.task_command_router.TaskCommandRouter/SandboxStdinWriteV2`, `POST /modal.task_command_router.TaskCommandRouter/SandboxStdioReadV2`, `POST /modal.task_command_router.TaskCommandRouter/SandboxWaitUntilReady`, `POST /modal.task_command_router.TaskCommandRouter/TaskExecPoll`, `POST /modal.task_command_router.TaskCommandRouter/TaskExecStart`, `POST /modal.task_command_router.TaskCommandRouter/TaskExecStdinWrite`, `POST /modal.task_command_router.TaskCommandRouter/TaskExecStdinWriteStream`, `POST /modal.task_command_router.TaskCommandRouter/TaskExecStdioRead`, `POST /modal.task_command_router.TaskCommandRouter/TaskExecWait`, `POST /modal.task_command_router.TaskCommandRouter/TaskMountDirectory`, `POST /modal.task_command_router.TaskCommandRouter/TaskSnapshotDirectory`, `POST /modal.task_command_router.TaskCommandRouter/TaskSnapshotFilesystem`, `POST /modal.task_command_router.TaskCommandRouter/TaskUnmountDirectory`.

<!-- END generated: served-operations -->

<!-- BEGIN generated: feed-effects (go run ./ingest/cmd/twindocs modal; do not edit) -->

**Feed effects.** No write emits a feed effect; watch requests instead. Each call appears on the event feed (`/_rystic/events`) as a `request` event, and reading the record back shows what it changed.

<!-- END generated: feed-effects -->

## Scenarios

<!-- BEGIN generated: scenarios (go run ./ingest/cmd/twindocs modal; do not edit) -->

The simulator ships 4 scenarios; the quickstart boots `modal_app_states`.

| Scenario | What it is for | What it seeds | Clock |
|---|---|---|---|
| `modal_app_states` (default) | Six apps standing across the app lifecycle in two environments | app 6, environment 2, function 5, image 1, secret 2 | 2025-12-20T12:00:00Z |
| `modal_map_backlog` | An ephemeral thumbnail-batch app caught mid-run | app 1, blob 3, dict_entry 2, environment 1, function 2, function_call 3, function_input 9, image 1, queue_item 4, task 2 | 2025-12-20T12:00:00Z |
| `modal_nightly_etl` | A deployed nightly-etl app on its fourth version with one built image, one mount of two source files, two secrets (one named, one owned by the app), three functions and one class, plus four calls whose inputs have not run, three blobs holding last night's results, two finished container tasks, three checkpoint dict entries and two queued replay requests. | app 1, blob 3, class 1, dict_entry 3, environment 1, function 3, function_call 4, function_input 4, image 1, mount 1, mount_file 2, queue_item 2, secret 2, task 2 | 2025-12-20T12:00:00Z |
| `modal_sandbox_fleet` | A sandbox fleet under one app | app 1, environment 1, exec 3, image 2, sandbox 4, sandbox_tag 4, secret 1, task 4, task_mount 3 | 2025-12-20T12:00:00Z |

What each scenario holds:

- **`modal_app_states`**: One initializing, one ephemeral with a live heartbeat, one detached, one deployed and two stopped (one by its owner, one by a keyboard interrupt), with five functions sharing one image and two named secrets, one in each environment.
- **`modal_map_backlog`**: Two functions on one image, a six-input map not yet run, with two inputs the caller resubmitted and one whose arguments are a blob, a canceled spawn, a two-input spawn map, three blobs, two tasks, two progress dict entries and four upload requests waiting in a queue.
- **`modal_sandbox_fleet`**: Four sandboxes standing running, exited, timed out and terminated on two images (one a filesystem snapshot), with one named secret attached to the running sandbox, four tags, four tasks, three directories mounted into two of those tasks and three completed exec records.

Boot one by name, or load one into a running simulator:

```bash
rystic run modal-twin -d --port 0 --scenario modal_app_states
curl -s -X POST "$RYSTIC_URL/_rystic/scenario" -d '{"name":"modal_app_states"}'
```

<!-- END generated: scenarios -->

## Seeding state

The simulator keeps one register per kind of record, and `GET /_rystic/registers` lists each with its fields. Each register keys its records by the id Modal gives that kind of record:

```bash
curl -s "$RYSTIC_URL/_rystic/registers" | jq -c '[.registers[] | select(.id == "state_app" or .id == "state_function" or .id == "state_sandbox") | {(.id): .key_fields}] | add'
# -> {"state_app":["app_id"],"state_function":["function_id"],"state_sandbox":["sandbox_id"]}
```

To start a test from an app that already exists, seed it and read it back:

```bash
curl -s -o /dev/null -w '%{http_code}\n' -X POST "$RYSTIC_URL/_rystic/seed" -d '{"state_app":{"ap-Seed000000000000000001":{"app_id":"ap-Seed000000000000000001","name":"nightly-exports","description":"nightly-exports","environment_name":"main","app_state":"APP_STATE_DEPLOYED"}}}'
# -> 204
curl -s "$RYSTIC_URL/_rystic/inspect" | jq -c '.state_app["ap-Seed000000000000000001"] | {name, app_state}'
# -> {"name":"nightly-exports","app_state":"APP_STATE_DEPLOYED"}
```

`modal.App.lookup("nightly-exports")` then returns that app. A seeded function or sandbox is a record to read: it has no code and no running process behind it.

A reset empties every register and puts the clock back at its start:

```bash
curl -s -o /dev/null -w '%{http_code}\n' -X POST "$RYSTIC_URL/_rystic/reset"
# -> 204
curl -s "$RYSTIC_URL/_rystic/inspect" | jq -c 'keys'
# -> []
curl -s "$RYSTIC_URL/_rystic/version" | jq -c '{initial_clock}'
# -> {"initial_clock":"2026-01-01T00:00:00Z"}
```

[Registers](https://www.rystic.ai/docs/concepts/worlds.md#registers) explains register fields, and [Scenarios and seeding](https://www.rystic.ai/docs/concepts/worlds.md) covers the seed response, refusals, boot files and the seed gate.

## Features

<!-- BEGIN generated: features (go run ./ingest/cmd/twindocs modal; do not edit) -->

Each feature has its own page:

- [Dicts and queues](https://www.rystic.ai/docs/simulators/modal/features/dicts-and-queues.md): Share data between your test and your functions with named dicts and queues, which the simulator keeps until a reset.
- [Functions](https://www.rystic.ai/docs/simulators/modal/features/functions.md): Call your Modal functions with remote, spawn and map, or deploy them and call them by name: each call runs your code as a local process and returns its real result.
- [The Python your code runs on](https://www.rystic.ai/docs/simulators/modal/features/python-runtime.md): The simulator's Docker image carries a Python with the Modal SDK for your code to run on, and you can point the simulator at your own.
- [Rate limits](https://www.rystic.ai/docs/simulators/modal/features/rate-limits.md): Turn on Modal's documented rate limits, so a call past parametrized function creation's allowance returns RESOURCE_EXHAUSTED.
- [Sandboxes](https://www.rystic.ai/docs/simulators/modal/features/sandboxes.md): Create sandboxes and run real commands in them, with stdin, exit codes, tags and a filesystem API, as local processes on the simulator's machine.

<!-- END generated: features -->

## Determinism and reset

Ids come from counters that a reset rewinds, so the same calls get the same ids on every run: [First calls](#first-calls) creates `ap-1`. The clock starts at `2026-01-01T00:00:00Z`, or at the scenario's own time, as [Seeding state](#seeding-state) reads it back after a reset.

A function's `timeout` also ends its call once that many real seconds have passed, so the 10-second timeout in [Functions](https://www.rystic.ai/docs/simulators/modal/features/functions.md) fires without a clock move.

[Reset and determinism](https://www.rystic.ai/docs/concepts/reset-and-determinism.md) covers reset, the clock and the RNG.

## Limitations

<!-- BEGIN generated: known-gaps (go run ./ingest/cmd/twindocs modal; do not edit) -->

**Known issues.**

- A function served as a web endpoint gets no URL: `get_web_url()` returns an empty string, and no HTTP request reaches the function. Workaround: Call the function with `.remote()`.
- Calling a generator function with `.remote_gen()` fails with `UnimplementedError`. Workaround: Return a list from the function and call it with `.remote()`.
- A function that a scenario or a seed adds cannot be looked up: `Function.from_name()` raises `ValueError` when the SDK reads it. Workaround: Deploy the functions your test calls from your own code, after the scenario loads.
- `modal app logs` and `modal app history` fail: the simulator serves no log fetch or deployment history for the command line. `modal app list` shows 0 tasks for every app, and `modal container list` is empty. `modal app stop` reads an id the simulator made, such as `ap-1`, as a name and finds no app. Workaround: Stop an app by its name, with `modal app stop` and `--yes` or with `modal.App.lookup(name).stop()`. Count running commands with the simulator's compute view, `/_rystic/inspect?view=compute`.
- Volumes and tunnels fail with `UnimplementedError`, and so do a sandbox's `reload_volumes` and `create_connect_token`. `wait_until_ready` returns once the sandbox has started, whether or not the sandbox is ready. After `unmount_image` the files the image brought stay at the path. Workaround: Pass data to a function as arguments or through a `modal.Dict` or a `modal.Queue`. Poll with `exec` until a sandbox is ready, and mount an image at a path your test does not read after the unmount.
- A background process ends when the command that started it returns. With isolation on, two commands in one sandbox do not share `127.0.0.1`, so one cannot reach a server the other started. Workaround: Start a server and its client in one command, such as one `sh -c` line.
- An image is not built: packages and commands it adds are missing from the sandbox or function, and a build that fails on Modal passes. Variables it sets with `Image.env` and local files it adds do reach your code. Workaround: Install what your code imports into the Python the simulator runs it on.
- `current_function_call_id()` and `current_input_id()` return an attempt token. A schedule whose cron line is outside five fields with lists, ranges, steps and names, such as `@daily`, a six-field line or `L`, is accepted and never runs. An app the simulator stops records no `stopped_by`. The simulator refuses a call to a stopped app at once; Modal accepted one sent 6 ms after the stop and refused one sent 258 ms after it. Workaround: Do not assert on input ids or on who stopped an app. Write a schedule as a five-field cron line or a `modal.Period`. Do not rely on a call made in the instant after a stop being accepted.

<!-- gaps-claim -->
Beyond the known issues, 4 documented responses have no test yet and 411 behaviors are not modeled. The details follow.

**Not tested.** 262 tests compare the simulator with the real service. 4 documented responses have no test yet:

| Operation | Status | Why |
|---|---:|---|
| `iv_grpc_modal_client_ModalClient__AppCreate` | 200 | no known request reaches it |
| `iv_grpc_modal_client_ModalClient__AppGetOrCreate` | 200 | no known request reaches it |
| `iv_grpc_modal_task_command_router_TaskCommandRouter__TaskExecWait` | 200 | no known request reaches it |
| `iv_grpc_modal_task_command_router_TaskCommandRouter__TaskSnapshotDirectory` | 200 | no known request reaches it |

**Not modeled.** Behavior the simulator does not model, by operation:

- A container's output is read once the container has taken a call of the app, and from then on line by line as it writes it: what it wrote before its first call, such as a class's enter, arrives with that call, and a line it has not ended waits for its newline, so a prompt or a progress bar that ends no line shows only when the container ends. A container that takes no call is not read. (`iv_grpc_modal_client_ModalClient__AppGetLogs`)
- An item names no function_call_id or input_id and carries no timestamp_ns, and its timestamp is the read's instant, not the write's. (`iv_grpc_modal_client_ModalClient__AppGetLogs`)
- A non-empty environment_name, and the refusal of a name no environment holds. (`iv_grpc_modal_client_ModalClient__AppGetOrCreate`)
- The simulator treats each as it treats no object_creation_type. (`iv_grpc_modal_client_ModalClient__AppGetOrCreate`)
- A period is counted from the publish's own instant on the simulator's clock. A clock move that ends exactly a whole number of periods after the deploy may or may not reach the run due there: the move starts from where the requests after the publish left the clock, a few milliseconds either side of that instant, so a test moves a little past a due time. A move's runs are handed to containers when the move ends, so right after it they are queued and finish within seconds. (`iv_grpc_modal_client_ModalClient__AppPublish`)
- A schedule runs on the simulator's clock, not on the wall clock: nothing runs until a test moves the clock past a due time, and one move runs a function at most 100 times, skipping the rest. The runs one move brings due start together, side by side up to the function's container limit, where the service runs each at its own time. (`iv_grpc_modal_client_ModalClient__AppPublish`)
- A scheduled function a scenario or a seed adds runs with no caller, so a call its code makes back on the simulator that needs a credential is refused: deploy it from the test's own code instead. (`iv_grpc_modal_client_ModalClient__AppPublish`)
- The simulator starts a container of the new definition for the next call, so a call right after a redeploy runs the new code. (`iv_grpc_modal_client_ModalClient__AppPublish`)
- The simulator names the input by the new token alone, so an await on the earlier token is refused as an unknown token is. (`iv_grpc_modal_client_ModalClient__AttemptRetry`)
- The simulator's token never expires. (`iv_grpc_modal_client_ModalClient__AuthTokenGet`)
- The simulator's blob ids are bl-`<n>`, shorter than the service's bl- and 22 letters and digits. (`iv_grpc_modal_client_ModalClient__BlobCreate`)
- Whether the service refuses a request whose methods name a function of another app, or whose only_class_function contradicts the methods list, is undocumented here. (`iv_grpc_modal_client_ModalClient__ClassCreate`)
- Whether a dict in another environment or another workspace is refused NOT_FOUND or PERMISSION_DENIED. (`iv_grpc_modal_client_ModalClient__DictClear`)
- A request naming a non-default environment_name, and a request naming an environment that does not exist. (`iv_grpc_modal_client_ModalClient__DictGetOrCreate`)
- The bound on max_objects. (`iv_grpc_modal_client_ModalClient__DictList`)
- A key or value past whatever size limit the service enforces on dict entries. (`iv_grpc_modal_client_ModalClient__DictUpdate`)
- The service sends a build's task_logs in batches while it builds, then the result. (`iv_grpc_modal_client_ModalClient__ImageJoinStreaming`)
- Whether a partition's TTL state is reset or dropped by a clear. (`iv_grpc_modal_client_ModalClient__QueueClear`)
- Whether a delete of an ephemeral queue still being heartbeated behaves differently from a named one. (`iv_grpc_modal_client_ModalClient__QueueDelete`)
- Whether an unauthenticated or wrongly-scoped credential is refused before the queue lookup on this method specifically. (`iv_grpc_modal_client_ModalClient__QueuePut`)
- … and 391 more

<!-- END generated: known-gaps -->

Release notes: [Changelog](https://www.rystic.ai/docs/simulators/modal/changelog.md)

---

Source: https://www.rystic.ai/docs/simulators/modal · Markdown: https://www.rystic.ai/docs/simulators/modal.md
