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

# ConTree SDK

Run commands in remote sandboxes, keep their filesystem changes, and try different
paths from the same saved state. Use Python for execution and session history;
ConTree stores the filesystem images on the server.

Start with [Your first sandbox](https://docs.tokenfactory.nebius.com/sandboxes/sdk/python_sdk/getting-started.md). It covers credentials, a base image,
and a complete program that prints `Hello from ConTree!`. Then continue in order:

1. [Your first sandbox](https://docs.tokenfactory.nebius.com/sandboxes/sdk/python_sdk/getting-started.md)
2. [Import a Docker image](https://docs.tokenfactory.nebius.com/sandboxes/sdk/python_sdk/images.md)
3. [Build a Docker image](https://docs.tokenfactory.nebius.com/sandboxes/sdk/python_sdk/building-images.md)
4. [Advanced usage](https://docs.tokenfactory.nebius.com/sandboxes/sdk/python_sdk/advanced.md)

Your sandbox can keep more than its latest result. Save a checkpoint, try an
experiment on another branch, and return to the baseline without repeating setup.
Continue with [Work with a Session](https://docs.tokenfactory.nebius.com/sandboxes/sdk/python_sdk/session-model.md) to learn how
snapshots, branches, rollback, and persistent history fit together.

## Choose your next task

| I want to… | Read |
| - | - |
| Understand sessions, snapshots, and branches | [Work with a Session](https://docs.tokenfactory.nebius.com/sandboxes/sdk/python_sdk/session-model.md) |
| Select components and control their behavior | [Advanced usage](https://docs.tokenfactory.nebius.com/sandboxes/sdk/python_sdk/advanced.md) |
| Upload inputs and download an output | [Work with sandbox files](https://docs.tokenfactory.nebius.com/sandboxes/sdk/python_sdk/files.md) |
| Continue work after restarting Python | [Save and resume a session](https://docs.tokenfactory.nebius.com/sandboxes/sdk/python_sdk/sessions.md) |
| Try a change and return to a checkpoint | [Branch, switch, and roll back](https://docs.tokenfactory.nebius.com/sandboxes/sdk/python_sdk/branching.md) |
| Stream output or run several processes in one sandbox | [Advanced: control a running sandbox](https://docs.tokenfactory.nebius.com/sandboxes/sdk/python_sdk/operation.md) |
| Import a Docker image | [Import a Docker image](https://docs.tokenfactory.nebius.com/sandboxes/sdk/python_sdk/images.md) |
| Build a filesystem from a Dockerfile | [Build a Docker image](https://docs.tokenfactory.nebius.com/sandboxes/sdk/python_sdk/building-images.md) |
| Give an agent access to a sandbox | [LangChain DeepAgents](https://docs.tokenfactory.nebius.com/sandboxes/sdk/integrations/langchain.md) |
| Run Harbor tasks in a ConTree environment | [Run Harbor on ConTree](https://docs.tokenfactory.nebius.com/sandboxes/sdk/integrations/harbor.md) |
| Change SDK policy or replace a component | [Customize the SDK](https://docs.tokenfactory.nebius.com/sandboxes/sdk/python_sdk/customization.md) |
| Upgrade an existing application | [SDK migration guide](https://docs.tokenfactory.nebius.com/sandboxes/sdk/python_sdk/migration.md) |

## What persists?

The default sandbox reuses one VM between commands. Normal context exit and
explicit `snapshot()` save filesystem changes. An exception discards changes
since the last completed snapshot. The default policy also snapshots after 10
idle seconds. Snapshots are lightweight and can run after every command, but they
stop the VM. Processes and memory do not survive. An unchanged filesystem can
produce the same `image_uuid`; this is normal.

Select `session_type=ContreeSession` or `ContreeAsyncSession` to save each command
automatically in a separate VM. `disposable=True` leaves the session image
unchanged. See [Save after every command](https://docs.tokenfactory.nebius.com/sandboxes/sdk/python_sdk/session-model.md#save-after-every-command).

History is in memory by default. Supply a SQLite store and a session ID to resume
after Python exits. The store keeps references; filesystem images remain on the
ConTree server. See [Save and resume a session](https://docs.tokenfactory.nebius.com/sandboxes/sdk/python_sdk/sessions.md).

## Advanced control

Use [Advanced usage](https://docs.tokenfactory.nebius.com/sandboxes/sdk/python_sdk/advanced.md) to select components, manage ownership,
and follow build events. [Advanced: assemble a sandbox yourself](https://docs.tokenfactory.nebius.com/sandboxes/sdk/python_sdk/manual-sandbox.md) shows explicit assembly.
Use [Advanced: control a running sandbox](https://docs.tokenfactory.nebius.com/sandboxes/sdk/python_sdk/operation.md) to manage subprocesses and their event stream.
