Sandboxes that auto-pause when your agent goes idle
You don’t write the code that cleans up after an agent. A sandbox nobody calls pauses after 5 minutes with its memory kept, stops after 30 with its files kept, and is never deleted unless you say so; the next call wakes it.
- A microVM per sandbox
- Starts in 0.15 s
- $0.018/h, billed per second
How to set a sandbox’s idle timeout
Keep the defaults, or set your own
By default a sandbox pauses after 5 idle minutes, stops after 30 and is never deleted. Set any of the three timers, in seconds, when you create it; 0 turns one off.
Hold it awake for long work
Start a build or a test run that nobody calls into with
keep_awake, and the sandbox will not pause under it. Give it a timeout too.Let the next call wake it
A call, an SSH login or a web request wakes a paused sandbox in about 0.1 s. A stopped one starts again with
resume_sandbox, or at the next call withwake_when_stoppedon.
from pethost.sandboxes import Lifecycle, Sandboxes, SandboxSettings
sandboxes = Sandboxes() # reads PETHOST_TOKEN
lifecycle = Lifecycle(
pause_after_idle_seconds=60, # paused after an idle minute
stop_after_idle_seconds=3600, # stopped after an idle hour
delete_after_idle_seconds=7 * 86400, # deleted after an idle week
)
sandbox = sandboxes.create_sandbox("base", settings=SandboxSettings(lifecycle=lifecycle))
# Work nobody calls into while it runs: keep_awake holds the pause off, for an hour at most.
install = "python3 -m venv env && env/bin/pip install pandas scikit-learn"
sandboxes.run_command(sandbox.sandbox_id, command=install, keep_awake=True, timeout_seconds=3600, wait_seconds=0)id=$(pethost sandbox new --pause-after 1m --stop-after 1h --delete-after 168h)
pethost sandbox run "$id" --keep-awake --timeout 1h -d -- 'python3 -m venv env && env/bin/pip install pandas scikit-learn'Why auto-pause on Pethost
Paused, not lost
Auto-pause keeps memory and processes: a dev server, a REPL’s variables and an agent’s conversation go on at the next call, in about 0.1 s, as if nothing had happened.
30% while it waits
A paused sandbox costs 30% of its running price, $0.0054 an hour for SMALL, by the second. You pay the full price only while it works.
Then its files alone
After 30 idle minutes it stops: running programs end, and every file stays, encrypted, at $0.03 per GiB a month of its own data, never of empty space.
Only real activity counts
Calls, open streams and links, SSH sessions, web requests, agent turns and
keep_awakecommands keep it awake. A background process alone does not: it pauses with the sandbox.Set per sandbox
Set the timers when you create a sandbox, change them later with
update_sandbox, or let a template carry them for every sandbox made from it.No lifetime cap
No sandbox has a maximum lifetime. One kept awake runs until you stop it, one left alone costs less at each step, and none is deleted unless you set a timer.
Idle timeouts for each use
An agent’s session
Claude Code in the cloud pauses 5 minutes after its last turn. With the stop timer off, it keeps its processes while it waits, and each idle hour costs 30% of a running one.
A sandbox per user of your app
Pause after 1 to 5 idle minutes, stop after 30 and delete after a week: users who come back within the week find their sandbox, and the ones who leave stop costing.
Batch jobs and evals
No pause, a stop after an idle minute and a delete after ten, or
delete_sandboxat the end: a finished run is gone within minutes.
What idle time costs
Take one SMALL sandbox that an agent works in for 2 hours a day and leaves idle for the other 22, over a 30-day month. Paused while idle, it costs $4.64 of usage: 60 hours at $0.018 and 660 at $0.0054. Left running, it would cost $12.96. Stopped while idle, with 5 GiB of its own data, it costs $1.22, but each start then boots it again, its processes gone. Per-second billing says how each of those seconds is counted.
Waking a stopped sandbox
By default a call into a stopped sandbox is refused, and a request to one of its ports is answered 503, until resume_sandbox starts it. With wake_when_stopped on, it wakes at a call, an SSH login or a web request as a paused one does: in about 0.2 s, or up to about 10 s per GiB after a long stop. Its vCPUs then count against your plan while it is stopped. It suits a sandbox that a webhook calls now and then.
Limits
A sandbox may pause or stop before its timers. Nothing is lost: the next call wakes it as usual, and its state_message says why. When a workspace’s included usage and balance are both spent, its running and paused sandboxes stop; nothing is deleted.
How it compares
Other vendors cap how long a sandbox lives. As their pages read on 21 November 2026, E2B’s sessions last up to 1 hour on Hobby and 24 hours on Pro, a pause starting the count again; Modal’s sandboxes live 5 minutes by default and 24 hours at most; and Vercel Sandbox’s sessions last 45 minutes on Hobby and 24 hours on Pro. Pethost sets no cap: a sandbox pauses and stops by its timers, and lives until you, or a delete timer you set, remove it.
Every sandbox, in numbers
Pethost Agent Sandboxes are cloud VMs for AI agents. Each is a Firecracker microVM with its own kernel and root inside: it starts in about 0.15 s, pauses with its memory while the agent thinks, and wakes at the next call. Billed by the second, in the EU.
- ~0.15 s to start a sandbox from a template
- ~0.1 s to wake a paused one, memory and processes as they were
- $0.018/h for 2 vCPU, 4 GiB and 10 GiB while running
- 1 s billing step: each run rounded up to a second, 10 s at least
- $0 to create or start a sandbox
Measured on our servers on 18 November 2026, through an API 16 ms away: a create’s median 123 ms (SMALL) to 158 ms (XLARGE), a resume 124 ms, a command to a paused sandbox 80 ms.
Questions
Will a long build be paused halfway?
Not when you start it with keep_awake: the sandbox does not pause for idleness while that command runs. Give it timeout_seconds too, so that a command that hangs does not keep it awake for good.
Can a sandbox never pause?
Yes: set pause_after_idle_seconds to 0. It then runs, billed as running, until its stop timer or you stop it.
How do I know when a sandbox will pause?
get_sandbox answers with next_state and next_state_time: what its timers do next, paused, stopped or deleted, and when. They are absent while something keeps it awake.
Everything else a sandbox does
- Pauses with its memoryA paused sandbox keeps its memory, processes and files at 30% of the price, and the next call wakes it in about 0.1 s, exactly where it was.
- Billed by the second, starts freeRunning time by the second from $0.018 an hour, paused time at 30% of that, a stopped sandbox by the GiB of its own files. Creating and starting one cost nothing.
- A microVM with its own kernelEach sandbox is a Firecracker microVM with its own Linux kernel and root inside: install anything, run Docker, change any file. It starts in about 0.15 s.
- Code execution in one callRun the code your model writes and get its exit code and output in one call, stream long jobs, edit files by exact replacement, and open a terminal in the browser.
- Claude Code and Codex, installedClaude Code, Codex and OpenCode run in every sandbox with every permission: one call gives one a prompt, another streams each tool call, and your API key stays outside.
- A desktop with ChromeEvery sandbox has a 1280×800 screen with Chrome: click, type and screenshot in one call, drive it with Playwright or Puppeteer, or watch it live and take over.
- Plain SSH, scp and tunnelsssh, scp, sftp and ssh -L into any sandbox with a workspace key or a token as the password; a login wakes a paused one.
- A URL for every portA dev server on port 3000 answers at its own HTTPS address, public or behind a token, and a visit wakes a paused sandbox in about 0.2 s.
- Save a sandbox as a templateSet a sandbox up once and save it as a template, packages and Docker images included; start as many sandboxes as you need from it, each in about 0.22 s.
- Only the hosts you allowList the domains, IPs and ports a sandbox may reach: every other host is refused, even in DNS, and a change applies while it runs.
- API keys the sandbox never holdsCode in the sandbox sees a placeholder. Its requests still work: the real API key is put in on the way out, only to the hosts you name.
- See everything a sandbox didCPU, memory, disk and network for 24 hours, and every change of state, command, host reached and agent turn, as a list or a live stream.
Give your agent a computer in 0.15 s
From $0.018 an hour for 2 vCPU and 4 GiB, billed by the second. Paused, 30% of that. Starting one is free.