Modal
Type: full-code · Vendor: Modal Labs · Language: Python · License: Apache-2.0 · Status: active · Status in practice: mature · First released: 2022
Serverless compute platform that turns Python functions into autoscaled cloud containers and exposes Sandboxes as ephemeral, secure runtimes for executing AI-generated code on demand.
Description. Modal is an AI infrastructure platform built by Modal Labs. Developers decorate Python functions with `@app.function` (optionally with a GPU, image, schedule, or `modal.Sandbox` reference) and Modal containerises and runs them in the cloud with sub-second cold starts and autoscaling. For agentic workloads the headline primitive is the Sandbox: a constructor (`Sandbox.create`) that programmatically spins up isolated containers to run untrusted or LLM-generated code, with filesystem, directory, and memory snapshots to checkpoint and restore state.
Agent loop shape. Modal is not itself an agent runtime; it is the substrate. Agent frameworks call `Sandbox.create()` to obtain an ephemeral container, send code or shell commands into it, observe stdout/stderr/files, optionally snapshot the filesystem or memory, and either reuse, detach, or terminate the Sandbox. Scheduled functions use the `schedule=modal.Period(...)` or `modal.Cron(...)` parameter on `@app.function` so the entry-point runs on a cadence without external orchestration.
Primary use cases
- secure sandboxed execution of LLM-generated code
- GPU-backed inference and fine-tuning
- scheduled / cron-driven serverless jobs
- containerised batch compute for agents
Key concepts
- App (docs) — Container for a set of related Modal Functions: `app = modal.App("name")`.
- Function (docs) — Python function decorated with `@app.function(...)`; Modal builds an image and runs it in the cloud.
- Sandbox → sandbox-isolation (docs) — Ephemeral isolated container created at runtime via `Sandbox.create` for executing untrusted/agent code.
- Sandbox snapshots → agent-resumption (docs) — Filesystem, directory, and memory snapshots that save and restore Sandbox state.
- Schedule (Period / Cron) → scheduled-agent (docs) — `schedule=modal.Period(...)` or `modal.Cron(...)` on `@app.function` runs the function on a cadence.
Patterns this full-code implements —
- ★★Agent Resumption
Sandbox memory and filesystem snapshots checkpoint state and can be restored as exact clones.
- ★★Code Execution
Sandboxes are advertised explicitly as the primitive for executing LLM-generated code.
- ★★Sandbox Isolation
Sandbox is the headline isolation primitive: ephemeral, secure containers for untrusted code.
- ★★Scheduled Agent
`@app.function(schedule=modal.Period(...))` or `modal.Cron(...)` runs a function on a cadence.
- ★Async Tool Handle
Modal's job-queue pattern is exactly start-tool-plus-poll-tool: .spawn() returns a FunctionCall handle immediately without waiting, the work runs in the background, and the result is fetched later vi…
Neighbourhood
Click any neighbour to follow the lineage. Scroll to zoom, drag to pan.