Archive a sandbox to its filesystem, and unarchive it back - #228
Merged
drappier-charles merged 5 commits intoAug 26, 2026
Conversation
sandbox.archive() keeps the filesystem changes made over the image and releases the compute; unarchive() writes them back over a new instance. Both wait for the background export/restore to finish unless wait=False, and both work as SandboxInstance.archive("name") like fork does.
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>
Contributor
Author
🤖 Devin AI EngineerI'll be helping with this pull request! Here's what you should know: ✅ I will automatically:
Note: I can only respond to comments from users who have write access to this repository. ⚙️ Control Options:
|
DEPLOYED sat in the archiving statuses and ARCHIVED in the restoring ones, the very statuses a failed export or restore reverts to, so a failure looked like progress and polled for the full 30 minutes. The entry status is now tolerated only while the operation starts. Also exercises the whole lifecycle against a real sandbox: an app behind a preview, archived, given back, the same preview URL serving again, and the sandbox deleted. Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
drappier-charles
marked this pull request as ready for review
August 26, 2026 00:59
…rst wait 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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
The control plane can now archive a sandbox — export the filesystem changes it made over its image, then release its compute — and unarchive it later. This exposes both as sandbox methods, in the async and the sync SDK, on the instance and on the class:
Both the export and the restore run in the background (minutes for a few gigabytes), so
wait=Trueis the default and polls the sandbox record:archiveuntilARCHIVED,unarchiveuntilDEPLOYED, both with a configurabletimeout(30 min) andinterval(2 s). A sandbox that leaves the states the operation goes through — say a failed export gives it back asDEPLOYED/FAILED— raises instead of waiting out the timeout.Both forms share one descriptor, so the class-level and the instance form cannot drift:
The instance form writes the refreshed record back into the shared
SandboxConfiguration, sosandbox.fs/sandbox.processand a forced session URL keep working across the call.Generated client:
archive_sandbox/unarchive_sandbox, theSandboxArchive/SandboxArchiveRestoremodels, and theARCHIVING/ARCHIVED/UNARCHIVINGstatuses.The integration test is gated behind
RUN_SLOW_TESTS: an archive and its restore take minutes each way, well past the one-minute budget.Link to Devin session: https://app.devin.ai/sessions/43a2b5615507438a8abb55723c9298e3
Requested by: @drappier-charles
Note
Medium Risk
Introduces long-running lifecycle operations with status polling; incorrect wait logic could mislead callers about when the filesystem is safe to write, though changes follow existing sandbox API patterns and are well covered by unit tests.
Overview
Adds sandbox archive/unarchive to the Python SDK so callers can export writable filesystem state to the archive store (releasing compute) and later restore it onto a new instance with processes restarted from saved configuration—not live memory.
Generated client: new
POST /sandboxes/{name}/archiveandunarchivehelpers (sync/async),Sandbox.archivemetadata models (SandboxArchive, restore progress), and deployment statusesARCHIVING,ARCHIVED, andUNARCHIVING.High-level API:
SandboxInstanceandSyncSandboxInstanceexposearchive()andunarchive()on both the class (by name, likedelete) and the instance. By default they poll untilARCHIVEDorDEPLOYED(30 min timeout, 2 s interval), withwait=Falseto return immediately; failed or unexpected status transitions raiseSandboxAPIErrorinstead of hanging. Instance calls refresh the embedded sandbox record sofs/processkeep working.Tests: mocked coverage for wait/timeout/failure paths plus opt-in slow integration tests (
RUN_SLOW_TESTS) for filesystem retention and preview URL stability across archive/restore.Reviewed by Cursor Bugbot for commit 8218851. Bugbot is set up for automated code reviews on this repo. Configure here.