# Daytona Snapshots — Reproducible AI Workspaces > Daytona Snapshots freeze a sandbox state — files, processes, environment — and create new sandboxes in milliseconds. Build agent tree search & benchmarks. ## Install Save as a script file and run: ## Quick Use 1. Have a Daytona sandbox configured (`pip install daytona-sdk`) 2. Set up the base state with `sandbox.process.exec(...)`, then call `sandbox.snapshot(name="...")` 3. Spawn branches with `daytona.create_from_snapshot(snapshot_id)` --- ## Intro Daytona Snapshots freeze a complete sandbox state — files, installed packages, environment variables, and even running processes (where supported) — into an immutable image. Spin up new sandboxes from a snapshot in milliseconds. Best for: agent tree-search algorithms, reproducible benchmark fixtures, branching exploration where multiple agents try different approaches from the same starting state. Works with: Daytona Python / TypeScript SDK. Setup time: 1 minute. --- ### Take a snapshot ```python from daytona import Daytona daytona = Daytona() # Set up a base environment sandbox = daytona.create() sandbox.process.exec("apt-get install -y postgresql") sandbox.process.exec("git clone https://github.com/example/app /work") sandbox.process.exec("cd /work && npm install") # Freeze the state — fast restore for downstream tasks snapshot_id = sandbox.snapshot(name="app-base-2026-05-07") ``` ### Spin up many sandboxes from one snapshot ```python # Each sandbox starts at the snapshot state — no re-install, no clone sb_lint = daytona.create_from_snapshot(snapshot_id) sb_test = daytona.create_from_snapshot(snapshot_id) sb_e2e = daytona.create_from_snapshot(snapshot_id) # Run different things in parallel sb_lint.process.exec("npm run lint") sb_test.process.exec("npm test") sb_e2e.process.exec("npx playwright test") ``` ### Tree search for agents ```python def explore(snapshot, depth=0, max_depth=3): if depth >= max_depth: return evaluate(snapshot) candidates = generate_next_actions(snapshot) best_score = -float("inf") best_action = None for action in candidates: sb = daytona.create_from_snapshot(snapshot) sb.process.exec(action.command) new_snapshot = sb.snapshot() score = explore(new_snapshot, depth + 1, max_depth) if score > best_score: best_score, best_action = score, action return best_score ``` Each branch is a real sandbox with real state — agents can run tests, observe failures, and decide based on actual outcomes rather than hallucinated predictions. ### Reproducible benchmarks ```python # Bench fixture — frozen state for SWE-Bench / HumanEval / etc fixture = daytona.create_from_snapshot("swebench-django-3.2.fixture") # Apply the agent's patch fixture.fs.upload_file("/repo/patch.diff", patch_text) fixture.process.exec("cd /repo && git apply patch.diff") # Run the test suite result = fixture.process.exec("cd /repo && pytest tests/django/") score(result) ``` Same fixture for every model run — no flaky environment differences. --- ### FAQ **Q: Are snapshots free?** A: Snapshots count toward your Daytona storage quota. Free tier includes some snapshot storage; production usage is metered per-GB-month. Check daytona.io/pricing for current rates. **Q: How big can a snapshot be?** A: Snapshots can be tens of GBs (full Linux + dependencies + data). Daytona uses copy-on-write under the hood — creating a sandbox from a snapshot doesn't duplicate the data, so spawning many branches from one snapshot is cheap. **Q: Are snapshots cross-account-shareable?** A: Yes — snapshots can be made public or shared within an organization. Useful for distributing benchmark fixtures or starter environments across a team. --- ## Source & Thanks > Built by [Daytona](https://github.com/daytonaio). Apache-2.0 (core). > > [daytona.io/docs](https://www.daytona.io/docs) — Snapshots documentation --- ## 快速使用 1. 配好 Daytona sandbox(`pip install daytona-sdk`) 2. 用 `sandbox.process.exec(...)` 搭基础状态,调 `sandbox.snapshot(name="...")` 3. 用 `daytona.create_from_snapshot(snapshot_id)` 起分支 --- ## 简介 Daytona Snapshot 把完整 sandbox 状态 —— 文件、装好的包、环境变量、甚至运行中进程(支持时)—— 冻结成不可变镜像。从快照启新 sandbox 毫秒级。适合 agent 树搜索算法、可复现 benchmark fixture、多个 agent 从同起点试不同方案的分支探索。需要 Daytona Python / TypeScript SDK。装机时间 1 分钟。 --- ### 拍快照 ```python from daytona import Daytona daytona = Daytona() # 搭基础环境 sandbox = daytona.create() sandbox.process.exec("apt-get install -y postgresql") sandbox.process.exec("git clone https://github.com/example/app /work") sandbox.process.exec("cd /work && npm install") # 冻结状态 —— 下游任务快速恢复 snapshot_id = sandbox.snapshot(name="app-base-2026-05-07") ``` ### 从一个快照起多个 sandbox ```python # 每个 sandbox 都从快照状态开始 —— 不重装、不重 clone sb_lint = daytona.create_from_snapshot(snapshot_id) sb_test = daytona.create_from_snapshot(snapshot_id) sb_e2e = daytona.create_from_snapshot(snapshot_id) # 并行跑不同的事情 sb_lint.process.exec("npm run lint") sb_test.process.exec("npm test") sb_e2e.process.exec("npx playwright test") ``` ### Agent 树搜索 ```python def explore(snapshot, depth=0, max_depth=3): if depth >= max_depth: return evaluate(snapshot) candidates = generate_next_actions(snapshot) best_score = -float("inf") best_action = None for action in candidates: sb = daytona.create_from_snapshot(snapshot) sb.process.exec(action.command) new_snapshot = sb.snapshot() score = explore(new_snapshot, depth + 1, max_depth) if score > best_score: best_score, best_action = score, action return best_score ``` 每个分支都是带真实状态的真实 sandbox —— agent 能跑测试、观察失败、基于真实结果决策,而不是幻觉预测。 ### 可复现 benchmark ```python # Bench fixture —— SWE-Bench / HumanEval 等的冻结状态 fixture = daytona.create_from_snapshot("swebench-django-3.2.fixture") # 打 agent 的补丁 fixture.fs.upload_file("/repo/patch.diff", patch_text) fixture.process.exec("cd /repo && git apply patch.diff") # 跑测试套件 result = fixture.process.exec("cd /repo && pytest tests/django/") score(result) ``` 每次模型跑用同一个 fixture —— 没有 flaky 环境差异。 --- ### FAQ **Q: Snapshot 免费吗?** A: Snapshot 算进 Daytona 存储配额。免费档含一定 snapshot 存储;生产用按 GB-月计费。看 daytona.io/pricing 拿当前费率。 **Q: Snapshot 能多大?** A: Snapshot 能到几十 GB(完整 Linux + 依赖 + 数据)。Daytona 底层用写时复制 —— 从 snapshot 起 sandbox 不复制数据,从一个 snapshot 起很多分支成本很低。 **Q: Snapshot 跨账号能共享吗?** A: 能 —— snapshot 可以公开或在组织内共享。给团队分发 benchmark fixture 或起步环境很有用。 --- ## 来源与感谢 > Built by [Daytona](https://github.com/daytonaio). Apache-2.0 (core). > > [daytona.io/docs](https://www.daytona.io/docs) — Snapshots documentation --- Source: https://tokrepo.com/en/workflows/daytona-snapshots-reproducible-ai-workspaces Author: Daytona