Skip to content

feat(python/sandbox): add snapshot API and start/stop lifecycle#2713

Merged
Ramon Nogueira (ramon-langchain) merged 4 commits intomainfrom
rn/sandbox-snapshot-api
Apr 14, 2026
Merged

feat(python/sandbox): add snapshot API and start/stop lifecycle#2713
Ramon Nogueira (ramon-langchain) merged 4 commits intomainfrom
rn/sandbox-snapshot-api

Conversation

@ramon-langchain
Copy link
Copy Markdown
Contributor

Summary

  • Add snapshot CRUD: create_snapshot, capture_snapshot, get_snapshot, list_snapshots, delete_snapshot, wait_for_snapshot
  • Add sandbox start/stop: start_sandbox, stop_sandbox on client, plus start() / stop() convenience methods on Sandbox / AsyncSandbox
  • Extend create_sandbox / sandbox to accept snapshot_id as an alternative to template_name, with vcpus, mem_bytes, fs_capacity_bytes resource params
  • Add Snapshot model
  • All methods implemented for both sync and async clients
  • Backwards compatible — existing template_name callers are unchanged

Test plan

  • 447 existing unit tests still pass
  • New tests for snapshot CRUD, start/stop, snapshot-based sandbox creation, validation errors
  • Ruff lint clean

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.
Comment thread python/langsmith/sandbox/README.md Outdated
Comment thread python/langsmith/sandbox/README.md Outdated
Comment thread python/langsmith/sandbox/README.md Outdated
Comment thread python/langsmith/sandbox/README.md
Comment thread python/langsmith/sandbox/README.md Outdated
- 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
@ramon-langchain Ramon Nogueira (ramon-langchain) marked this pull request as ready for review April 14, 2026 18:24
@ramon-langchain Ramon Nogueira (ramon-langchain) merged commit c286fc3 into main Apr 14, 2026
36 checks passed
@ramon-langchain Ramon Nogueira (ramon-langchain) deleted the rn/sandbox-snapshot-api branch April 14, 2026 18:29
Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

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

💡 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)
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge 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 👍 / 👎.

Ramon Nogueira (ramon-langchain) added a commit that referenced this pull request Apr 15, 2026
## 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)
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.

2 participants