← Back to blog

Pause and Resume: How It Works

Deep dive into Runra Sandbox's pause and resume feature — preserve agent workspace state without keeping environments active.

One of the key differentiators of Runra Sandbox is the pause and resume capability. Let's dive into how it works and why it matters for AI agent workloads.

The problem with always-active sandboxes

In a traditional sandbox model, every sandbox consumes resources for its entire lifetime. If an agent finishes a task and you want to preserve its state for later, you have two options:

1. Keep it running — wastes compute and costs money

2. Terminate it — lose all workspace state (installed packages, cloned repos, file changes, running processes)

Neither is ideal for agent workloads where sessions can span hours or days.

How pause and resume works

Runra Sandbox uses state preservation rather than full VM snapshots:

Active sandbox (running)
  ↓ pause
Paused sandbox (state preserved, no runtime)
  ↓ resume
Active sandbox (state restored, ready to execute)

What's preserved during pause

  • File system: All files, installed packages, dependencies, and workspace changes
  • Environment: Environment variables, working directory, user context
  • Process state: Running background processes are snapshot-ready

What's not preserved

  • Active connections: Open network connections are closed on pause
  • In-flight commands: Currently executing commands complete before pause
  • Temporary runtime state: In-memory caches that haven't been persisted

Use cases

Long-running coding agents

An agent works on a feature for 2 hours, makes progress, then pauses until the developer reviews the output. The agent resumes with all context intact.

User-specific development workspaces

Each user gets their own sandbox with their cloned repo, installed tools, and preferences. When they log off, the sandbox pauses. When they return, it resumes instantly.

Multi-step research agents

A research agent processes data in stages over multiple days. Between stages, the sandbox pauses and resumes with the intermediate results preserved.

Background automation

A cron-triggered agent runs daily. The sandbox pauses between runs, preserving installed tools and cached data, so each run starts from a warm state.

API

// Create and set up a sandbox
const sandbox = await runra.sandboxes.create({
  image: "node:22",
  resources: { cpu: 2, memoryMb: 4096 },
});

await sandbox.exec("git clone https://github.com/acme/app.git");
await sandbox.exec("cd app && npm install");

// Pause — state preserved, no runtime cost
await sandbox.pause();

// Resume — state restored
await sandbox.resume();

// Continue where we left off
await sandbox.exec("cd app && npm test");

Billing

  • Active sandboxes: Billed per sandbox-hour
  • Paused sandboxes: No active runtime charge; only workspace and snapshot storage costs apply

This makes it cost-effective to keep agent workspaces warm without paying for idle compute.

Learn more