Set the application contract
Choose these values in application code:- Modal Environment;
- one supported Function and Sandbox region selector;
- Function and Sandbox CPU and memory;
- Function and Sandbox Images;
- timeouts, retries, and scaling limits;
- warm-capacity settings.
retries=0, min_containers=0, and no Sandbox warm pool.
Deploy the Function once
Verify placement before mutation
The Function decorator andComputerConfig.runtime.modal_region must use the same selector.
Borrow entry compares that request with the observed Function and target placement. A public
narrow selector can resolve to concrete AWS, GCP, or Azure region identifiers. A granted granular
selector requires an exact runtime match. Missing or unverifiable placement fails before desktop
mutation.
Inspect cost-bearing settings
Clean up in ownership order
- Stop new work.
- Wait for the Function call or seal its outcome.
- Release the borrow.
- Close the owner and terminate its Sandbox.
- Confirm that no unintended warm or billable capacity remains.
ComputerSandboxManager.cleanup_expired(..., dry_run=True) before any stale-resource cleanup.
