> ## Documentation Index
> Fetch the complete documentation index at: https://docs.tensorlake.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# How does the sandbox lifecycle work?

> Frequently asked questions about Tensorlake Sandbox lifecycle — ephemeral vs named sandboxes, suspend, resume, terminate, and timeouts.

<head>
  <script type="application/ld+json">
    {`{
            "@context": "https://schema.org",
            "@type": "FAQPage",
            "mainEntity": [
              {
                "@type": "Question",
                "name": "How do you keep an AI agent's environment alive between turns or sessions?",
                "acceptedAnswer": {
                  "@type": "Answer",
                  "text": "There are two general approaches: pause-in-place and snapshot-and-restore. Pause-in-place suspends the live VM so its filesystem, memory, and running processes are preserved, then resumes under the same identifier — useful for keeping an agent's working memory and open processes alive between turns. Snapshot-and-restore captures a reusable artifact you can boot into a fresh VM later — useful for retrying from a checkpoint or branching experiments. In Tensorlake, these are exposed as suspend/resume on named sandboxes and snapshot/restore via filesystem or memory snapshots."
                }
              },
              {
                "@type": "Question",
                "name": "What's the difference between ephemeral and named sandboxes?",
                "acceptedAnswer": {
                  "@type": "Answer",
                  "text": "Ephemeral sandboxes have no name and run until you terminate them or they time out. Named sandboxes support suspend/resume so you can pause between tasks and pick up where you left off."
                }
              },
              {
                "@type": "Question",
                "name": "What states does a Tensorlake Sandbox move through?",
                "acceptedAnswer": {
                  "@type": "Answer",
                  "text": "Every sandbox moves through these states: Pending (being scheduled and booted), Running (live and accepting commands, file operations, and process execution), Snapshotting (a reusable snapshot artifact is being captured), Suspending (named sandbox is being paused — manually or via timeout_secs), Suspended (named sandbox is paused — consumes no compute, state preserved), and Terminated (sandbox has stopped — final state, cannot be reversed). Create starts the sandbox in Pending; from Running, you can suspend (named only), snapshot, or terminate. Ephemeral sandboxes skip Suspending and Suspended."
                }
              },
              {
                "@type": "Question",
                "name": "How do I suspend a Tensorlake Sandbox?",
                "acceptedAnswer": {
                  "@type": "Answer",
                  "text": "Call suspend on a named sandbox. The sandbox transitions to Suspended, consumes no compute, and preserves its state. Call resume on the same sandbox ID to bring it back to Running. Suspend is not supported for ephemeral sandboxes."
                }
              },
              {
                "@type": "Question",
                "name": "When should I use suspend vs. snapshot?",
                "acceptedAnswer": {
                  "@type": "Answer",
                  "text": "Both preserve sandbox state, but they serve different purposes. Suspend pauses this sandbox so you can resume it later under the same ID. Snapshot captures a reusable artifact you can restore into a new sandbox."
                }
              },
              {
                "@type": "Question",
                "name": "What happens when a sandbox times out?",
                "acceptedAnswer": {
                  "@type": "Answer",
                  "text": "Ephemeral sandboxes are terminated when their timeout elapses. Named sandboxes transition to Suspending then Suspended when timeout_secs elapses, preserving state for later resume rather than terminating."
                }
              },
              {
                "@type": "Question",
                "name": "Can I reverse a terminated sandbox?",
                "acceptedAnswer": {
                  "@type": "Answer",
                  "text": "No. Terminated is the final state. To restore prior state into a new sandbox, capture a snapshot before termination and create a new sandbox from that snapshot."
                }
              },
              {
                "@type": "Question",
                "name": "How is suspend/resume different from stopping and restarting a Docker container?",
                "acceptedAnswer": {
                  "@type": "Answer",
                  "text": "Stopping a Docker container ends its processes and discards memory state — restarting goes through a cold boot and re-initializes the application. Tensorlake suspend pauses a named sandbox in place: filesystem, memory, and running processes are preserved. Resume brings it back to Running under the same sandbox ID with the same in-memory state, so an agent harness can pick up exactly where it left off."
                }
              }
            ]
          }`}
  </script>
</head>

## How do you keep an AI agent's environment alive between turns or sessions?

There are two general approaches:

* **Pause-in-place** — suspend the live VM so its filesystem, memory, and running processes are preserved, then resume under the same identifier. Useful for keeping an agent's working memory and open processes alive between turns.
* **Snapshot-and-restore** — capture a reusable artifact you can boot into a fresh VM later. Useful for retrying from a checkpoint or branching experiments.

In Tensorlake, these map to [suspend/resume](#how-do-i-suspend-a-tensorlake-sandbox) on named sandboxes and [snapshot/restore](/sandboxes/snapshots) via filesystem or memory snapshots.

## What's the difference between ephemeral and named sandboxes?

|                      | Ephemeral                            | Named                                    |
| -------------------- | ------------------------------------ | ---------------------------------------- |
| **Created with**     | `tl sbx create`                      | `tl sbx create <name>`                   |
| **Suspend / Resume** | Not supported                        | Supported                                |
| **Reference by**     | ID only                              | ID **or** name                           |
| **Use when**         | Short-lived tasks, one-off execution | Multi-step work, persistent environments |

Ephemeral sandboxes have no name and run until you terminate them or they time out. Named sandboxes support suspend/resume so you can pause between tasks and pick up where you left off.

## What states does a Tensorlake Sandbox move through?

Every sandbox moves through these states. Create starts the sandbox in `Pending`; from `Running`, you can suspend (named only), snapshot, or terminate. Ephemeral sandboxes skip `Suspending`/`Suspended`.

| State            | What it means                                                                   |
| ---------------- | ------------------------------------------------------------------------------- |
| **Pending**      | Sandbox is being scheduled and booted. Transitions to `Running` automatically.  |
| **Running**      | Sandbox is live and accepting commands, file operations, and process execution. |
| **Snapshotting** | A reusable snapshot artifact is being captured. Returns to `Running` when done. |
| **Suspending**   | Named sandbox is being paused — manually or via `timeout_secs`.                 |
| **Suspended**    | Named sandbox is paused. Consumes no compute; state preserved.                  |
| **Terminated**   | Sandbox has stopped. Final state; cannot be reversed.                           |

For the full state diagram, see [Lifecycle](/sandboxes/lifecycle).

## How do I suspend a Tensorlake Sandbox?

Call `suspend` on a named sandbox. The sandbox transitions to `Suspended`, consumes no compute, and preserves its state. Call `resume` on the same sandbox ID to bring it back to `Running`. Suspend is not supported for ephemeral sandboxes.

## When should I use suspend vs. snapshot?

Both preserve sandbox state, but they serve different purposes:

* **Suspend** pauses *this* sandbox so you can resume it later under the same ID.
* **Snapshot** captures a reusable artifact you can restore into a *new* sandbox.

| Scenario                        | Use Suspend | Use Snapshot |
| ------------------------------- | ----------- | ------------ |
| Pause and resume later          | ✅           | ❌            |
| Save cost when idle             | ✅           | ❌            |
| Keep agent memory alive         | ✅           | ❌            |
| Retry from a checkpoint         | ❌           | ✅            |
| Run experiments from same state | ❌           | ✅            |
| Clone environment               | ❌           | ✅            |

See [Snapshots](/sandboxes/snapshots) for save-and-restore.

## What happens when a sandbox times out?

Ephemeral sandboxes are **terminated** when their timeout elapses. Named sandboxes transition to **Suspending** then **Suspended** when `timeout_secs` elapses, preserving state for later resume rather than terminating.

## Can I reverse a terminated sandbox?

No. `Terminated` is the final state. To restore prior state into a new sandbox, capture a snapshot before termination and create a new sandbox from that snapshot.
<Note>**Coming soon:** a `restart` operation that re-boots a terminated sandbox from
its last snapshot.</Note>

## How is suspend/resume different from stopping and restarting a Docker container?

Stopping a Docker container ends its processes and discards memory state — restarting goes through a cold boot and re-initializes the application. Tensorlake `suspend` pauses a named sandbox in place: filesystem, memory, and running processes are preserved. `resume` brings it back to `Running` under the same sandbox ID with the same in-memory state, so an agent harness can pick up exactly where it left off.
