A lot of agents start the same way: docker run --rm on the server that runs the agent, with the model’s code mounted in. It works, until the agent runs code from strangers, or from a web page it read, and someone points out that the container shares the server’s kernel and probably its network. Moving to a hosted microVM fixes the boundary. It also changes a dozen small assumptions your code makes. This checklist is for finding them before production does.
1. The image
- List what your Docker image installs. System packages, language runtimes, tools the agent calls. A hosted sandbox starts from a template; check that one covers your needs or build your own.
- Pin it. Use a digest, not a tag, so two runs a week apart get the same environment.
- Remove what the agent does not need. Compilers,
ssh, cloud CLIs. Every tool in the image is a tool a prompt injection can use.
On Sandscale, built-in templates include Python, Node and Go images (builtin:python, builtin:node, builtin:go), and templates are pinned by digest. image on create accepts an OCI image pinned by name@sha256:....
2. Files in and out
- Replace bind mounts. Locally you mounted a directory; now files go in and out through the API. Decide what goes in (a few files, or the whole project) and what comes back (a diff, artifacts, nothing).
- Stop relying on the host seeing changes live. Read results back explicitly at the end of a step.
- Check sizes. Uploading a large repository per run is slow and wasteful; start from a snapshot with the repository already in place, or clone inside the box.
See uploading a project into a sandbox.
3. Network
- Find out what your container could reach. With Docker’s default bridge network, the container usually had outbound internet and could often reach services on the host or the same network. List what the agent actually needs.
- Start closed. Default to no network, then allow package registries and the specific APIs a task needs.
- Check DNS. If DNS resolves everything, data can leave through lookups. See DNS exfiltration.
- Remove access to internal services. A hosted box will not be on your private network, which is the point. If a task needs an internal API, expose a narrow endpoint for it.
On Sandscale, sandboxes start with network mode none; allowlist uses your organization’s egress allowlist and package registry presets.
4. Secrets
- Find every secret in the old setup.
-e API_KEY=...ondocker run, mounted credential files, cloud instance credentials reachable from the container (the metadata endpoint is a classic). - Give each run only what its task needs, scoped and short-lived.
- Assume code in the box can read what you give it. That does not change with a VM. See secrets in environment variables.
On Sandscale, Vault hands secrets to a run in memory as environment variables and ends them with the run; values stay out of prompts, logs, the API’s answer and the audit log.
5. Timeouts and lifetimes
- Map your old timeout to three.
docker runwithtimeoutin front was one clock. Now there is the sandbox’s lifetime, each command’s limit, and your HTTP client’s timeout. See three timeouts for agent sandboxes. - Handle orphans.
--rmcleaned up when your process exited. A hosted box survives your process; set a lifetime so it does not survive forever.
6. Output and errors
- Replace parsing of
dockerexit codes. A hosted API returns structured results. On Sandscale,run()returnsexitCode,stdout,stderr,timedOutandoomKilled. - Stream long commands instead of waiting for the end. See streaming sandbox output.
- Handle API errors separately from command failures. A 429 or a network error is not the model’s fault; retry it, do not report it. See handling sandbox API errors.
7. Concurrency and cost
- Check the provider’s limit on boxes at once against your peak. Add a queue in front if needed. See concurrency limits and queueing.
- Model cost from your real run shape: how long boxes exist, how much of that they work, and what size. See five ways agent sandboxes are billed.
- Right-size. Your local container probably had the whole server. See sizing a sandbox.
8. Records
- Label every box with the task, user and agent, so you can trace it.
- Decide what you log yourself and what the provider records. On Sandscale, every sandbox and API call lands in a hash-chained audit log, on every plan.
9. Rollout
- Run both side by side for a while: same tasks, old runner and new, compare results.
- Move the riskiest workloads first, the ones that run code from outside sources, not the safest.
- Keep the old path behind a flag until the new one has handled a bad day.
The gotcha list
Four that are easy to miss: a tool that silently needed network and now hangs; a test that wrote to /tmp on the host and read it back from the agent process; a secret that was in the image all along; and boxes left running after a deploy restarted the orchestrator. Each one is on the list above.