# Run a sandbox for days without losing your agent's state

> A sandbox your agent keeps across sessions: run it up to 7 days at a time and extend it, pause it with its memory and processes while the agent is idle, resume it with the next command, and what it costs.

URL: https://prized.dev/docs/sandboxes-long-running
Updated: 2026-10-25

A sandbox does not lose its state when a session ends: pause it, and it keeps its memory, running processes and files for as long as you keep it, billed for storage only; the next command resumes it, usually in under a second. Running, it gets 24 hours by default, up to 7 days at a time; the clock stops while it is paused, and you can extend it while it runs.

## 1. Create it for the long run [#1-create-it-for-the-long-run]

[Open Sandboxes](https://prized.dev/onboarding/sandboxes) to sign up and choose **Create API key**, then install the CLI and export the key in a new terminal:

```bash
curl -fsSL https://prized.dev/install.sh | sh
```

```bash
export PRIZED_API_KEY=dcp_…
```

```bash
ID=$(prized sandbox create --template prized-agent-v1 --max-runtime 7d --auto-pause 15m --label agent=support-bot)
```

`--auto-pause 15m` pauses it after 15 minutes with no command or file copy, so an idle agent costs no compute, and the label shows in `prized sandbox ls`. `--max-runtime 7d` needs a workspace that has paid in (a plan or a top-up): on the free credit a sandbox runs 60 minutes in all, so leave it out there ([Free tier](https://prized.dev/docs/sandboxes#free-tier)).

## 2. Use it across sessions [#2-use-it-across-sessions]

```bash
prized sandbox exec $ID -- 'nohup python3 -m http.server 8000 > server.log 2>&1 &'
prized sandbox exec $ID -- 'echo "step 1 done" >> notes.txt'
```

When the agent goes quiet the sandbox pauses on its own, or now with `prized sandbox pause $ID`. Days later, the next command resumes it first, with the server still running and the notes where they were:

```bash
prized sandbox exec $ID -- 'cat notes.txt && curl -s localhost:8000 > /dev/null && echo server up'
```

## 3. Keep it past 7 days [#3-keep-it-past-7-days]

Each resume starts a fresh 7 days of run time, so a sandbox that pauses at least once a week never runs out. Busy for more than 7 days straight? Extend it while it runs; it stops at 7 days from now, so extend again later ([Run time](https://prized.dev/docs/sandboxes#run-time)):

```bash
prized sandbox extend $ID --by 2d
```

## What to know [#what-to-know]

* **Paused state lives on one machine.** If that machine fails, the sandbox goes to `error` and what it held is lost: push work to git or copy it out as you go ([Pause and resume](https://prized.dev/docs/sandboxes#pause-and-resume)).
* **Deleting erases it,** by hand, by `--auto-delete`, or at the end of its run time.
* **On the free credit,** a paused sandbox is kept 30 days after its last use; once the workspace has paid in, until you delete it ([Paused retention](https://prized.dev/docs/sandboxes#paused-retention)).
* **Needs root, Docker or months on one machine?** Use a box: a Linux machine with sudo and no maximum run time ([Persistent cloud computer](https://prized.dev/docs/persistent-cloud-computer)).

## What it costs [#what-it-costs]

|  | 4 vCPU, 8 GB (the default) |
| --- | --- |
| Running, per hour | $0.261 |
| Working 2 hours a day for 30 days | $15.66 |
| Paused | No compute: its disk and memory count as paused storage, and a workspace's first 20 GB are included |

Each session also runs up to 15 idle minutes before `--auto-pause` pauses it. This shape holds 18 GB paused, inside the included 20 GB; past them, paused storage is $0.05 per GB-month ([Billing: Sandboxes](https://prized.dev/docs/billing#sandboxes)).
