# The sandbox and its state (/claude-and-chatgpt-2/architecture/the-sandbox-and-its-state)

---
type: Document
title: "The sandbox and its state"
description: "The cloud workspace each Claude session gets, a Python demo, where chat history lives, and when the VM is paused, restored or replaced. Also how a stateless model becomes a stateful session."
status: stable
order: 0.43
ksor:
  owner: team:panaversity
  audience: [ public ]
  approval:
    by: process:panaversity
    at: 2026-11-09T20:42:36Z
chapter: "F00A"
part: Front
expert_status: required
concepts: [ "Sandbox and state" ]
last_verified: 2026-11-09
sources:
  - id: cowork-architecture
    title: "Claude Cowork architecture overview (Anthropic, verified 2026-11-09)"
    resource: https://support.claude.com/en/articles/14479288-claude-cowork-architecture-overview
  - id: code-tab
    title: "Claude Desktop: Code tab docs (Anthropic, verified 2026-11-09)"
    resource: https://code.claude.com/docs/en/desktop?facet1=pdf
  - id: author-inspection
    title: "Panaversity's inspection of a cloud Claude session: a Python test run on November 8, 2026, and a process and environment inspection on November 9, 2026"
    resource: "appendix-reproducing-the-observations.md"
  - id: cloud-environments
    title: "Configure cloud environments (Anthropic, verified 2026-11-09)"
    resource: https://code.claude.com/docs/en/cloud-environments
  - id: claude-code-cloud
    title: "Use Claude Code in the cloud (Anthropic, verified 2026-11-09)"
    resource: https://code.claude.com/docs/en/claude-code-on-the-web
generated:
  at: 2026-11-09T20:42:36Z
  by: process:panaversity
trust_tier: unverified
build_id: sha256:46fd53c5d7ab1c14f6347908d45c9fdaecda4d914439923ee878bdcecd57803e
dirty: true
ksor_version: 0.0.60
---

### The session cloud workspace

**[Vendor-documented]** Each cloud session runs in its own temporary sandbox, on computers that Anthropic manages. No state is shared between sessions or between organizations.[^cowork-architecture] **[Observed]** In the session examined, the sandbox was a Linux microVM with Python, Node, a shell and file tools. This is the borrowed desk from [Where the work happens](../new-way-of-working/where-the-work-happens.md).

| Aspect | How it works | Basis |
| --- | --- | --- |
| Scope | One sandbox for each session, not shared with other chats | Vendor-documented |
| Persistence | Files and installed packages last from one turn to the next within the session | Observed |
| Lifetime (end of session) | Destroyed when the session ends | Vendor-documented |
| Lifetime (idle time) | Paused and later restored, or reclaimed and replaced | Vendor-documented for Claude Code cloud sessions. Inferred for the chat examined here |
| Background work | A process the shell detaches (with `nohup` or `&`) usually stops a few minutes after a reply ends. The harness's own background jobs run until their time limit | Tool-documented (the session's environment notes) |
| Network | Outbound traffic goes through a proxy, to allowed places only (an allowlist). Web lookups use separate tools | Vendor-documented and observed |
| Your computer | Reached only through the Claude desktop app, and only in the folders you connect | Vendor-documented and observed |

**[Vendor-documented]** Availability depends on the product and plan. Cloud tasks in a conversation are available on Pro, Max and Ultra, in beta on Team, and on Enterprise once an owner turns them on.[^cowork-architecture] Claude Code cloud sessions are available on Pro, Max and Team plans, and for Enterprise users with premium seats or Chat + Claude Code seats.[^cloud-environments] The desktop app's Code tab also lets you choose Local, Cloud, SSH or WSL for each session.[^code-tab] The settings that shape a cloud sandbox are in [Cloud environments and self-hosted runners](cloud-environments-and-self-hosted-runners.md).

### Demo: a Python program in the VM

**[Observed]** On November 8, 2026, a script named `hello_vm.py` was created, saved and run inside the session workspace.[^author-inspection] It printed:

```
Hello from the session VM!
Python: 3.13.18
OS: Linux-6.18.44-fc-v310-x86_64-with-glibc2.39
Working dir: /home/claude
Time (UTC): 2026-11-08 04:34
Squares 1-10: [1, 4, 9, 16, 25, 36, 49, 64, 81, 100] sum = 385
```

**[Observed]** Between writing the file and running it, the session was interrupted and resumed. The run had not happened. The file came back as a read-only copy from the conversation. **[Inferred]** The workspace had been replaced, because a restored VM keeps its own files. So anything installed or running was lost. A second change on November 9 is weaker evidence, as explained below.

The lesson: treat the VM as scratch space, a place for temporary work. Keep anything that matters in a delivered file, an artifact, Drive or a repository.

### Where chat history lives

**[Vendor-documented]** Sessions and files are saved to the user's Claude account.[^cowork-architecture] **[Observed]** The harness held its own working copy of the conversation in the VM. **[Inferred]** The browser also holds only a copy. The saved record is the one on the account.

| Place | What it holds | Survives a replaced VM? |
| --- | --- | --- |
| Anthropic backend | The stored conversation, reachable from any device | Yes |
| Browser or app | A cached copy, kept for display | It reloads from the backend (inferred) |
| Harness in the VM | The working context for each model call, plus a transcript on disk | Not if the VM is replaced. It is rebuilt from the backend (inferred) |

The chat survived the replaced VM in the demo, because the backend copy counts. In local Claude Code, the transcript lives on your machine.

### When the VM is paused, restored or replaced

**[Vendor-documented]** The sandbox is destroyed when the session ends.[^cowork-architecture] For Claude Code cloud sessions, Anthropic also documents what happens to an idle VM. "After a few minutes without activity, a session's VM pauses with its files saved. Your next message restores the same VM and starts Claude Code again." But "if the paused VM has since been reclaimed, reopening the session provisions a fresh VM." Reclaiming also stops background work that was still running.[^cloud-environments],[^claude-code-cloud]

**[Observed]** In the session examined here, two things were seen. During the demo, the file came back only as a read-only copy from the conversation. On November 9, PID 1 had been running for about 19 minutes, after a long idle gap.

**[Inferred]** The demo fits a reclaimed VM and a fresh one, because a restored VM keeps its files. The uptime is weaker evidence. A restored VM may not count paused time as uptime. So a short uptime alone does not prove a new machine. **[Unknown]** Whether this chat session follows the documented Claude Code rules, and how long a paused VM is kept before it is reclaimed.

**[Inferred]** Pausing and reclaiming save computing power and keep each session clean.

| Survives a reclaimed VM | Lost when the VM is reclaimed |
| --- | --- |
| The chat itself | Installed packages |
| Files from the conversation (restored as copies) | Running servers and background jobs |
| Artifacts and docs | Environment variables and temporary files |
| Memory and connected apps | Anything not written back into the conversation |
| Anything saved to your computer, Drive or a repository | |

In practice, plan for a fresh VM after a break, even though a short break may only pause it. Scripts should check for what they need and install it. Save important output outside the VM. [Projects](projects-coordination-on-top-of-sessions.md) build this habit into the product.

### Stateful sessions on a stateless model

The model is stateless, but the session around it remembers. The harness makes the difference.

- **Stateless model.** The model keeps no memory between calls. For each call, the harness builds the context from instructions, the relevant history, tool results and the current state. When the context grows too large, the harness may compact it, summarize it, or fetch only what it needs. The session examined was configured to auto-compact at 80%. Prompt caching makes repeated context faster to process, but it is not memory.
- **Stateful session.** Between calls, the harness holds a transcript, the VM's files, packages and tool results.

| Layer | State it holds | Lifetime |
| --- | --- | --- |
| Anthropic backend | The conversation | Saved to the account (vendor-documented). How long it is kept is not covered here |
| Harness and VM | Working files, the environment, the transcript on disk | Until the VM is reclaimed or the session ends |
| Outside stores (memory, artifacts, Drive, repositories) | Whatever you save there | As long as you keep it |

![How long each layer keeps state. Each layer keeps state longer than the one above it. Relative lifetimes, not to scale, drawn as bars along an arrow labeled longer-lived. One model call: a tiny bar, nothing kept between calls. Harness and VM: a short bar, until the session ends or the VM is replaced. Backend conversation: a longer bar, saved to the account. Outside stores: the longest bar, highlighted, as long as you keep them. Design for this layer.](img/how-long-each-layer-keeps-state.png)

The model is a stateless function. The harness turns it into a stateful agent. With the API or the Agent SDK, your own code holds that state.

[^cowork-architecture]: As verified on November 9, 2026. Claude Cowork architecture overview, Anthropic.
[^code-tab]: Claude Desktop: Code tab docs, Anthropic.
[^author-inspection]: Panaversity's inspection of a cloud Claude session. The method is in the appendix.
[^cloud-environments]: As verified on November 9, 2026. The page quotes the idle pause and restore. Configure cloud environments, Anthropic.
[^claude-code-cloud]: As verified on November 9, 2026. "Cloud sessions stop after a period of inactivity and the session's VM is reclaimed." Use Claude Code in the cloud, Anthropic.
