Skip to content

Restore a sandbox to one of its own snapshots - #230

Merged
drappier-charles merged 4 commits into
mainfrom
cdrappier/devin/sandbox-restore-snapshot
Aug 28, 2026
Merged

Restore a sandbox to one of its own snapshots#230
drappier-charles merged 4 commits into
mainfrom
cdrappier/devin/sandbox-restore-snapshot

Conversation

@devin-ai-integration

@devin-ai-integration devin-ai-integration Bot commented Aug 27, 2026

Copy link
Copy Markdown
Contributor

Summary

Exposes the new controlplane endpoint POST /sandboxes/{sandboxName}/snapshots/{snapshotId}/restore (blaxel-ai/controlplane#5290) in the SDK: the client is regenerated from the controlplane OpenAPI on main, and both the async and sync SandboxInstance gain a wrapper next to snapshot/list_snapshots/fork.

sandbox = await SandboxInstance.get("my-sandbox")
snapshot = await sandbox.snapshot("before-migration")
# ...later
await sandbox.restore(snapshot.id)  # -> SandboxRestoreResponse(name, snapshot_id)

Unlike fork, restore is in place: the sandbox keeps its name, URLs and previews, only the instance behind it is rebuilt from the snapshot, so anything written after the snapshot is lost. Like fork, the call returns as soon as the restore is accepted, without waiting for the instance.

Regenerating also pulled in the schedule endpoints/models the OpenAPI definition has gained since the last generation (list_schedules, get_sandbox_schedule_metrics, …) — generated-only, no hand-written code depends on them.

The integration test (tests/integration/core/sandbox/test_snapshots.py) writes a file, snapshots, writes a second file, restores, and asserts the first file is back and the second is gone. It is opt-in behind RUN_SLOW_TESTS because a full snapshot + restore round trip takes minutes.

Link to Devin session: https://app.devin.ai/sessions/b07a2ea049fb42c2a3598005bdc86bbb
Open in Devin Desktop: https://app.devin.ai/desktop/session/b07a2ea049fb42c2a3598005bdc86bbb?variant=devin
Requested by: @drappier-charles


Note

Medium Risk
Restore is destructive (rebuilds the live instance and drops post-snapshot state) and the SDK does not wait for readiness; callers must handle downtime like fork. Large generated client surface and enum/sort changes could affect code that relied on removed sort values.

Overview
Adds in-place sandbox restore to the SDK: regenerated client for POST /sandboxes/{name}/snapshots/{id}/restore and new restore(snapshot_id) on async and sync SandboxInstance, returning SandboxRestoreResponse. Unlike fork, the sandbox keeps its name and URLs while the instance is rebuilt from the snapshot; the call returns when the restore is accepted, not when the guest is back up.

OpenAPI regeneration also brings in workspace-level schedule observability (GET /schedules, /schedule-executions, /schedules/metrics) plus model tweaks: sandbox and execution status on schedule records, new metrics types, and removal of name sort options from sandbox-scoped schedule list enums (workspace list enums are separate).

Integration coverage adds an opt-in slow test (RUN_SLOW_TESTS) that snapshots, mutates the FS, restores, and asserts filesystem rollback. Test helpers gain mk3.1 gating via workspace feature generation_mk31 (skip_unless_generation_mk31, optional BL_REQUIRE_GENERATION_MK31=1) and BL_REGION override for default region.

Reviewed by Cursor Bugbot for commit f98d087. Bugbot is set up for automated code reviews on this repo. Configure here.

Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
@devin-ai-integration

Copy link
Copy Markdown
Contributor Author

🤖 Devin AI Engineer

I'll be helping with this pull request! Here's what you should know:

✅ I will automatically:

  • Address comments on this PR that start with 'DevinAI' or '@devin'.
  • Look at CI failures and help fix them

Note: I can only respond to comments from users who have write access to this repository.

⚙️ Control Options:

  • Disable automatic comment, CI, and merge conflict monitoring

drappier-charles and others added 3 commits August 27, 2026 23:07
Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
@drappier-charles
drappier-charles marked this pull request as ready for review August 28, 2026 00:38
@drappier-charles
drappier-charles merged commit 5edb52c into main Aug 28, 2026
17 of 19 checks passed
@drappier-charles
drappier-charles deleted the cdrappier/devin/sandbox-restore-snapshot branch August 28, 2026 00:39

@devin-ai-integration devin-ai-integration Bot left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ Devin Review: No Issues Found

Devin Review analyzed this PR and found no bugs or issues to report.

Devin Review

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant