English
Get started
Pethost Agent Sandboxes

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

  1. 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.

  2. 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.

  3. 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 with wake_when_stopped on.

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_awake commands 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_sandbox at 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.

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

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.

Start the free trial