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

# Migrate a Tensorlake sandbox worker to Sailboxes

> Give this guide to your coding agent to replace Tensorlake sandbox calls with the Sail SDK. Your worker can keep using Tensorlake for hosted Git repositories and versioned files.

## Sailboxes vs. Tensorlake: CPU minimums and memory billing

Sail charges for the CPU you use. A higher CPU limit alone does not increase the charge. Tensorlake charges for at least 20% of allocated CPU while the sandbox runs. It charges for the full allocation if it cannot measure CPU use. Sail bills for the RAM the Sailbox holds. Tensorlake bills for all allocated RAM while the sandbox runs. [Sail pricing](https://docs.sailresearch.com/sailboxes-pricing.md) · [Tensorlake pricing](https://www.tensorlake.ai/pricing)

## Create the Sailbox

Install the [Sail Python SDK](https://docs.sailresearch.com/reference/python-sdk.md) on the machine that runs your controller. Run `python -m pip install sail`. Sign in with `sail auth login`. Create one Sailbox per session. This example saves its ID in a local file. In your application, store the ID with the agent session.

```python theme={null}
from pathlib import Path
import sail

app = sail.App.find(name="migration-demo", mint_if_missing=True)
sb = sail.Sailbox.create(app=app, name="tensorlake-worker")
Path("sailbox-id.txt").write_text(sb.sailbox_id)
```

## Transfer files

Replace Tensorlake’s `sandbox.write_file(path, data)` with `sb.fs.write(path, data)`. Run this code from the directory that contains `worker.py` and `job.json`. The example worker reads `/tmp/job.json` and writes `/tmp/result.json` inside the Sailbox. Use the paths your worker needs.

```python theme={null}
sb.fs.write("/tmp/worker.py", Path("worker.py").read_bytes())
sb.fs.write("/tmp/job.json", Path("job.json").read_bytes())
```

If the worker uses Git on Tensorlake, give the Sailbox access to that repository. To move the repository, mirror its Git refs. Save uncommitted changes separately. An export of a pinned filesystem version contains the files from that version. Keep the version history on Tensorlake if you need rollback.

## Run your existing worker

Pass the command and its arguments to `sb.run()` as a single list.

```diff theme={null}
- result = sandbox.run("python3", ["/tmp/worker.py"])
+ result = sb.run(["python3", "/tmp/worker.py"], check=True)
  print(result.stdout)
```

## Reconnect after sleep

An idle Sailbox [sleeps automatically by default](https://docs.sailresearch.com/sailboxes-autosleep). Use the saved ID to find the same Sailbox. Read the result file. This operation wakes a sleeping Sailbox.

```python theme={null}
from pathlib import Path
import sail

sb = sail.Sailbox.get(Path("sailbox-id.txt").read_text().strip())
print(sb.fs.read("/tmp/result.json").decode())
```

Sleep preserves files and memory. [Termination deletes the Sailbox.](https://docs.sailresearch.com/sailboxes-lifecycle.md)

## Check the worker output

Run your worker with the same input on Tensorlake and on Sail. Compare the command output and the files from both runs.
