Skip to main content
Package installation often costs more than sandbox boot. This example installs OpenCode once, records the stopped sandbox as an integrity-checked snapshot, and launches fresh workers from that prepared filesystem.

Start a warm worker

1

Prepare the baseline

Create the worker verification script that the snapshot will carry into every worker:
verify-worker.sh
When the command exits, agent-base is stopped and ready to snapshot.
2

Create and verify the snapshot

Verify the captured snapshot before using it:
The snapshot captures the writable disk changes and pins the source image. It does not capture memory, running processes, network state, environment variables, or named volumes. Integrity verification detects later changes to those captured bytes; it does not attest who built the snapshot or whether its packages are trustworthy.
Snapshots preserve every file written to the guest disk, including shell history, tool configuration, and cached credentials. Build the baseline in a trusted workflow, and never authenticate OpenCode or place registry tokens, source code, or API keys in agent-base.
3

Launch a clean worker

Transfer the committed project tree into the worker:
Create a credential-free Git baseline and verify the worker boundary:
Start OpenCode after those checks pass:
Rootfs patches such as --copy-dir cannot be combined with --from-snapshot, so the worker boots first and receives the committed tree afterward. git archive excludes .git, checkout credentials, and untracked files such as a local .env; review the committed tree for secrets before sending it. Initializing a new repository inside the worker preserves useful diff workflows without copying host remotes or credentials. Each transferred or interactive workload sets its own process, file-descriptor, and per-file limits.Each launch receives its own writable layer. Changes made by one worker do not modify the snapshot, the host project, or another worker.
This worker uses microsandbox’s default public-internet profile so OpenCode can reach a configured provider. For sensitive projects, replace it with a deny-by-default allowlist for the provider and source hosts you need, and use host-held secrets instead of copying credentials into the worker.
Create more workers by changing the sandbox name:
4

Clean up

Remove the prepared sandbox and workers:
Remove the reusable snapshot only when you no longer need it:

Refresh the baseline

Snapshots are immutable. To update packages, recreate agent-base, then overwrite the named snapshot intentionally:
See Snapshots for archive, integrity, and portability details.