Skip to content

Persistent workspaces

Persistent state is useful for agents, browser sessions, caches, databases, and long-running services. It is also where sensitive data accumulates. Choose the smallest state mechanism that fits the workflow, and make the retention policy explicit before the sandbox starts.

NeedUseSecurity posture
One input file or result filemvmctl cp or mvmctl fsNarrowest boundary; preferred for generated-code tasks.
Read-only fixturesmvmctl run --add-dir ...:roHost data is exposed but not writable by the guest.
Local dev editsmvmctl run --profile dev --add-dir ...:rwWritable host share; use only for trusted dev workflows.
Stateful app datamanaged encrypted volumeEncrypted at rest when locked; plaintext exists while unlocked.
Fast retry or recoverysnapshot or cold modeCan contain memory, files, processes, prompts, and credentials.

Do not use a snapshot when a narrow output file is enough. Do not use a writable host share when a managed volume is enough.

Create a managed local volume:

Terminal window
mvmctl volume create agent-cache

Managed volumes are locked by default. Unlock before mounting:

Terminal window
mvmctl volume unlock agent-cache

Mount the unlocked volume into a running sandbox:

Terminal window
mvmctl volume mount agent-sandbox \
--volume agent-cache \
--guest /cache \
--rw

List mounts:

Terminal window
mvmctl volume ls agent-sandbox

Unmount and lock when the workflow is done:

Terminal window
mvmctl volume unmount agent-sandbox /cache
mvmctl volume lock agent-cache

Security rules:

  • volume mount refuses a managed volume while it is locked;
  • volume unlock creates plaintext state that must be treated as sensitive;
  • volume lock reseals the volume and removes plaintext after use;
  • keep volume names scoped to the workflow or project;
  • do not mount the same writable volume into unrelated sandboxes unless sharing state is the intent.

Ad-hoc host-backed mounts are useful when an existing encrypted host directory is the source of truth:

Terminal window
mvmctl volume mount agent-sandbox \
--volume project-data \
--host /absolute/path/to/data \
--guest /data

Use --rw only for trusted workflows:

Terminal window
mvmctl volume mount agent-sandbox \
--volume project-data \
--host /absolute/path/to/data \
--guest /data \
--rw

The host directory must live on encrypted backing storage. If encryption cannot be verified, the command should fail closed.

For model-generated code, third-party scripts, and code interpreter workloads, prefer copy-in/copy-out:

Terminal window
mvmctl cp ./input.json agent-sandbox:/work/input.json
mvmctl exec agent-sandbox -- python /work/task.py
mvmctl cp --max-bytes 16777216 agent-sandbox:/work/output.json ./output.json

Copy workflows reduce host exposure. Treat copied guest output as untrusted input when it returns to the host.

Volumes preserve selected filesystem state. Snapshots preserve machine state.

CapabilityVolumeSnapshot or cold state
Files onlyYesYes
Process memoryNoYes
Running process stateNoBackend-specific
Easier to inspectYesNo
Smaller retention surfaceUsuallyUsually not
Can contain secretsYesYes

Use a volume when you need durable files. Use cold mode or snapshots when you need to resume a whole machine state.

For a coding agent:

  1. Create a named sandbox with a short TTL.
  2. Copy the task input into /work.
  3. Mount a managed volume at /workspace only if the agent needs durable state.
  4. Keep network closed until the task has an approved egress need.
  5. Copy out bounded results.
  6. Stop, cold-pause, or destroy based on the retention decision.
  7. Lock volumes and record receipt/audit identifiers.

Example:

Terminal window
mvmctl volume create coding-agent-work
mvmctl volume unlock coding-agent-work
mvmctl up ./agent-image --name coding-agent
mvmctl volume mount coding-agent --volume coding-agent-work --guest /workspace --rw
mvmctl cp ./task.json coding-agent:/work/task.json
mvmctl exec coding-agent --timeout 120 -- python /work/run_task.py
mvmctl cp --max-bytes 16777216 coding-agent:/work/result.json ./result.json
mvmctl volume unmount coding-agent /workspace
mvmctl down coding-agent
mvmctl volume lock coding-agent-work

Before marking a stateful sandbox done:

  • stop compute with mvmctl down when it no longer needs to run;
  • lock every managed volume;
  • remove mounts that are no longer needed;
  • delete snapshots that no longer have a recovery purpose;
  • rotate credentials if generated code had access to them;
  • store receipt/audit identifiers with the job record;
  • review logs before attaching them to tickets, traces, or model context.

Stopping compute is not the same as erasing state. Volumes, logs, receipts, snapshots, caches, copied files, and generated artifacts may remain.