简介
Daytona Snapshot 把完整 sandbox 状态 —— 文件、装好的包、环境变量、甚至运行中进程(支持时)—— 冻结成不可变镜像。从快照启新 sandbox 毫秒级。适合 agent 树搜索算法、可复现 benchmark fixture、多个 agent 从同起点试不同方案的分支探索。需要 Daytona Python / TypeScript SDK。装机时间 1 分钟。
拍快照
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
# 每个 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 树搜索
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
# 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 或起步环境很有用。