Scale computer-use 2.0 with open-source drivers, cross-OS sandboxes, and benchmarks for training, evaluation, and data generation.
Rust agentai-agentapplecomputer-usecomputer-use-agentcontainerizationcuadesktop-automationhacktoberfestlumemacosmanusoperatorswiftvirtualizationvirtualization-frameworkwindowswindows-sandbox
fix(sandbox): suspend instead of delete VMs that have snapshots (#1248)
ddupont7f67fb2d8264
diff --git a/libs/python/cua-sandbox/cua_sandbox/sandbox.py b/libs/python/cua-sandbox/cua_sandbox/sandbox.pyindex 15bdb4ed9c..be0d6f67aa 100644--- a/libs/python/cua-sandbox/cua_sandbox/sandbox.py+++ b/libs/python/cua-sandbox/cua_sandbox/sandbox.py@@ -249,6 +249,7 @@ class Sandbox:self._runtime = _runtimeself._runtime_info = _runtime_infoself._ephemeral = _ephemeral+ self._has_snapshots = Falseself.telemetry_enabled = _telemetry_enabledself.screen = Screen(transport)self.mouse = Mouse(transport)@@ -289,6 +290,7 @@ class Sandbox:raise NotImplementedError("Snapshots are only supported for cloud sandboxes")image_desc = await self._transport.create_snapshot(name=name, stateful=stateful)+ self._has_snapshots = Truefrom cua_sandbox.image import Image as ImageCls# Get the original image from the transport for os_type/distro/version@@ -306,15 +308,22 @@ class Sandbox:)async def destroy(self) -> None:- """Disconnect and permanently delete the sandbox (VM/container)."""+ """Disconnect and permanently delete the sandbox (VM/container).++ If a snapshot was taken from this sandbox, it is stopped instead of+ deleted so that forks created from the snapshot remain valid.+ """if self.telemetry_enabled and _TELEMETRY_AVAILABLE and is_telemetry_enabled():record_event("sandbox_destroy", {"name": self.name, "ephemeral": self._ephemeral})await self._transport.disconnect()if isinstance(self._transport, CloudTransport):- await self._transport.delete_vm()+ if self._has_snapshots:+ await self._transport.suspend_vm()+ else:+ await self._transport.delete_vm()if self._runtime and self._runtime_info:vm_name = self._runtime_info.name or self.name or "cua-sandbox"- if self._ephemeral and hasattr(self._runtime, "delete"):+ if self._ephemeral and hasattr(self._runtime, "delete") and not self._has_snapshots:await self._runtime.delete(vm_name)else:await self._runtime.stop(vm_name)