fix: mirror CLI VM sandbox guards in SDK#538
Conversation
|
@cursoragent review |
|
@codex review |
Findings (ordered by severity)No issues found. I reviewed the VM-guard and
The behavior aligns with CLI guard semantics ( Open questions / assumptions
Change summary (secondary)
Optional environment optimization: since I installed |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 43bd41a5ec
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".


Summary
prime-sandboxesSDK for port exposure and SSH-related methodsis_vmhelpers to the sync and async sandbox clients so SDK consumers can branch on VM-backed sandboxes explicitlyis_vmbehaviorTesting
cd packages/prime-sandboxes && python -m pytest tests/test_vm_guards.py -x --no-headercd packages/prime-sandboxes && python -m pytest tests/test_command_transport_selection.py tests/test_models.py tests/test_client_retry.py tests/test_gateway_error_mapping.py tests/test_vm_guards.py --no-headercd packages/prime-sandboxes && python -m ruff check src/prime_sandboxes/sandbox.py tests/test_vm_guards.pyNote
Medium Risk
Changes runtime behavior for VM-backed sandboxes by turning previously-attempted operations into immediate
APIErrors, which could break callers relying on prior (failing) gateway behavior. Scope is limited to expose/SSH paths and is covered by new unit tests.Overview
Mirrors CLI behavior by failing fast on VM-backed sandboxes:
SandboxClient/AsyncSandboxClientnow guard port exposure and SSH operations (expose,unexpose,list_exposed_ports,create_ssh_session,close_ssh_session) and raise a clearAPIErrorinstead of issuing HTTP requests.Adds public
is_vm()helpers (sync + async) that delegate to the auth cache (with cold-cache fallback toGET /sandbox/<id>), and introducestest_vm_guards.pyto assert guards prevent HTTP calls on VMs while container-backed sandboxes still proceed normally.Reviewed by Cursor Bugbot for commit 5240e48. Bugbot is set up for automated code reviews on this repo. Configure here.