feat(python/sandbox): add snapshot API and start/stop lifecycle#2713
feat(python/sandbox): add snapshot API and start/stop lifecycle#2713Ramon Nogueira (ramon-langchain) merged 4 commits intomainfrom
Conversation
Add snapshot CRUD (create_snapshot, capture_snapshot, get_snapshot, list_snapshots, delete_snapshot, wait_for_snapshot) and sandbox start/stop lifecycle methods to both sync and async clients. Extend create_sandbox/sandbox to accept snapshot_id as an alternative to template_name for snapshot-based sandbox creation, with vcpus, mem_bytes, and fs_capacity_bytes resource params. Add Snapshot model, start/stop convenience methods on Sandbox and AsyncSandbox, and update README with usage examples.
- Replace 'rootfs' with 'sandbox files' in all public docs/docstrings - Add sb.capture_snapshot() and sb.delete() convenience methods on Sandbox/AsyncSandbox - Update README examples to use sb.capture_snapshot() and sb.delete() - Simplify snapshot description in README
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 30a9fca787
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "Codex (@codex) review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "Codex (@codex) address that feedback".
| ) from e | ||
| handle_client_http_error(e) | ||
|
|
||
| return self.wait_for_sandbox(name, timeout=timeout, headers=headers) |
There was a problem hiding this comment.
Handle stopped state when waiting after start
start_sandbox() now waits via wait_for_sandbox(), but that waiter only exits on ready or failed and treats every other lifecycle value as “keep polling.” This commit introduces stopped as a normal sandbox status, so if the status endpoint reports stopped after a start attempt (or callers wait on a stopped sandbox), the client will spin until timeout and raise ResourceTimeoutError instead of surfacing a terminal lifecycle error immediately.
Useful? React with 👍 / 👎.
## Summary JS counterpart to #2713 (Python). - Add snapshot CRUD: `createSnapshot`, `captureSnapshot`, `getSnapshot`, `listSnapshots`, `deleteSnapshot`, `waitForSnapshot` - Add sandbox start/stop: `startSandbox`, `stopSandbox` on client, plus `start()` / `stop()` / `captureSnapshot()` convenience methods on `Sandbox` - Extend `createSandbox` to accept `snapshotId` as an alternative to `templateName`, with `vcpus`, `memBytes`, `fsCapacityBytes` resource params - Add `Snapshot` type and related option interfaces - Backwards compatible — existing `templateName` callers are unchanged ## Test plan - [x] `tsc --noEmit` passes clean - [x] `eslint` passes (0 errors, 1 pre-existing warning)
Summary
create_snapshot,capture_snapshot,get_snapshot,list_snapshots,delete_snapshot,wait_for_snapshotstart_sandbox,stop_sandboxon client, plusstart()/stop()convenience methods onSandbox/AsyncSandboxcreate_sandbox/sandboxto acceptsnapshot_idas an alternative totemplate_name, withvcpus,mem_bytes,fs_capacity_bytesresource paramsSnapshotmodeltemplate_namecallers are unchangedTest plan