DocsGuides
Persistence
A Computer saves part of its state and restores it when you start it again: its cookies, localStorage, passkeys and learned skills. Its session files are temporary. Each kind of state has its own rule, listed below; there is no blanket promise for every file.
What persists
| State | While the Computer runs | After you start the Computer again |
|---|---|---|
| Cookies | Kept, and saved every few minutes while they change | Restored from the latest save; best effort |
| localStorage | Kept | Restored from the latest save, usually the last graceful stop, if the new browser version can read it |
| Learned skills, and which of Pine's skills are switched on | Kept | Restored from the latest save |
| Passkeys you approve | Kept | Restored; each passkey is saved when you approve it |
| Tabs | If the browser restarts, each session's tabs close and its next window opens blank | Not restored |
| IndexedDB, cache, history, service workers | May remain in the browser profile | Not restored |
Session files: working directory, HOME, attachments and downloads |
Kept | Not restored: download what you need before you stop, or save it as an artifact |
| Artifacts | Kept outside the Computer, in storage | The same files, also while the Computer is stopped. They are deleted 25 hours after the Computer is deleted |
| Sessions and agent turns | Sessions remain if the Computer's services restart, but a turn in progress ends and doesn't continue; check what it did before you run it again | Not restored: create new sessions |
| Session secrets | Cleared if the Computer's services restart | Not restored: send them again |
Saves cover cookies, learned skills and passkeys, and localStorage is saved separately when the browser stops, which a graceful stop guarantees. Session files are never saved. A turn's files and the browser's downloads last until the Computer stops; save important outputs in your own storage, or keep them as the Computer's artifacts.
What each lifecycle step does
computer.stop: try a final save, then shut down
Stop tries a final save of the Computer's state, then shuts it down. The Computer stops
taking new work, saves its cookies and skills, closes the browser to save
localStorage, and confirms the encrypted saves before it shuts down. If that
save fails or isn't confirmed in time, it shuts down anyway (see below).
Start the Computer later with its id, state key and capture keypair to restore
what was saved. Stop doesn't keep sessions, work directories, HOME,
attachments or downloads.
computer.stop waits up to 390 seconds by default (wait_timeout: in Ruby,
timeoutMs in TypeScript, timeout_seconds in Python; in Go the ctx bounds
the call) and returns true once the runtime this handle is bound to is no
longer running, or right away when the handle has no binding. If the wait runs
out, it returns false and the Stop carries on: call stop again on the same
handle to keep waiting. A true doesn't mean the final save succeeded, and
there's currently no way to read the save result.
Saving is best effort. If the save fails, or isn't confirmed within two minutes
(six when a paused Computer must be resumed first), the Computer still shuts
down and stop returns true. The next start restores the last save, and
anything not yet saved is lost. An older server instead raises
PineSandbox::StopSaveError and keeps the Computer running: call stop again
when the error's retryable? is true, or client.recover_computer to shut it
down and start from the last save.
computer.kill: shut down without waiting for a save
Kill shuts the Computer down without waiting for a save. Use it when something
has gone wrong and the Computer has to stop. Pine still tries a final save as
it shuts down, but doesn't confirm it, so a later start may restore only what
was saved before: the latest periodic save of cookies and skills, and an older
localStorage. Kill doesn't wait, and returns false if the request failed.
computer.checkpoint: save right away
Checkpoint saves cookies and learned skills without stopping the Computer, and
returns once the save is stored. It doesn't save localStorage or session
files. If nothing changed since the last save, it stores nothing and reports
skipped.
computer.pause and computer.resume: keep everything in memory
For projects with Pause enabled. Pause captures the Computer's whole memory,
so the Computer, its sessions and their state all survive, and resume brings
them back. Both wait for the operation to finish (timeout:, 360 seconds by
default). A paused Computer still reaches its expiry, and a resume that fails
never starts a fresh Computer in its place.
If the Computer's services restart
The browser profile and the session files stay. Session secrets are cleared and any turn in progress ends. Send the secrets again before you retry work that needs them.
If the browser restarts
The session's tabs close. Its next window opens on a blank page, and its other tabs are not restored.
Starting again
A Computer has to start again after a stop, a failure or maintenance. Starting it needs its id, state key and capture keypairs; the SDK uses them to restore the saved cookies, skills, passkeys and localStorage. To keep using a Computer that's still running instead, see Reuse a running Computer.
Cookies and localStorage are saved on different schedules, so one can be newer
than the other. A new start doesn't restore tabs, sessions, work
directories, attachments, downloads, HOME or session secrets. Create a new
session and send it its inputs and secrets again.
What to expect
Treat browser recovery as best effort. Don't make a browser
save your only copy of application data. Download important files to your own
storage before you stop the Computer: the working directory, HOME,
attachments and downloads last only until the Computer stops.
The keys your backend holds
Keep each Computer's state key and capture private keys on your backend.
PineSandbox::Computer.generate_credentials creates them with the Computer's
id: a 32-byte state key and a capture keypair. Save them before you create the
Computer; Getting started
shows how. Every save is sealed to your capture public key. On each attach,
the SDK uses your pk_ to get short-lived credentials for that Computer sandbox
only, and uses your private key to let the Computer restore the saved state.
Your private keys never leave your backend.
What this means for you:
- A leaked
pk_alone doesn't expose saved state: restoring it needs the Computer's private keys. - Pine's storage alone can't expose it either: decrypting a save needs both a key Pine holds and your private key.
- You can start a Computer from any server that has your
pk_and the Computer's id, state key and capture keypair. No key is tied to one machine.
Without these keys the Computer can't be started again and its saved state can't be read, so save them before you create it. The encryption details are internal to Pine and not part of your integration; for the bigger picture, see How a Computer works.
When saves happen
Cookies and learned skills are saved:
- Periodically, every few minutes while the Computer runs, and only when something changed.
- On
computer.checkpoint, right away. - On
computer.stop, which also saves localStorage and waits for both saves before the Computer shuts down, unless they fail or time out.
When a Computer shuts down without a stop, for example because it expired, Pine tries a final save within a short shutdown window but can't guarantee that it finishes.
API reference
computer.checkpoint, computer.stop and computer.kill are SDK methods.
The Computer API reference describes the routes behind them,
under Computer Lifecycle and State and Recovery, and the Attach routes the SDK
uses to restore state.