Skip to main content

Sailboxes vs. Modal: sandbox lifetime and memory pricing

A Sailbox has no fixed lifetime by default. It keeps its workspace when it sleeps. Modal limits each sandbox to 24 hours. Both platforms let memory use grow. Sail charges $0.008 per GiB-hour of RAM used. Modal charges about $0.024 per GiB-hour. Modal bills for the larger of two amounts: the RAM you request or the RAM you use.

Create the Sailbox

Install the Sail Python SDK on the machine that runs your controller. Run python -m pip install sail. Sign in with sail auth login. Create one Sailbox per session. This example saves its ID in a local file. In your application, store the ID with the agent session.

Transfer files

Modal’s filesystem.write_text(text, path) takes the file contents first. Sail’s fs.write(path, data) takes the destination first. Run this code from the directory that contains worker.py and job.json. The example worker reads /tmp/job.json and writes /tmp/result.json inside the Sailbox. Use the paths your worker needs.
Install the worker dependencies in a Sail image. Export the required files from the Modal Volume, or use storage that both workers can access. A file copy does not preserve how the volume saves changes.

Run your existing worker

For commands that need only the final output, replace Sandbox.exec() with sb.run(). This call waits for the command to finish.
Use the Sail process API for live logs or interactive input.

Reconnect after sleep

An idle Sailbox sleeps automatically by default. Use the saved ID to find the same Sailbox. Read the result file. This operation wakes a sleeping Sailbox.
Sleep preserves files and memory. Termination deletes the Sailbox.

Check the worker output

Run your worker with the same input on Modal and on Sail. Compare the command output and the files from both runs.