Body:
When Sandbox.create() is called with an mcp config and the MCP gateway fails to start (non-zero exit code or exception from commands.run), the already-created sandbox is never killed. This leaves orphaned sandboxes consuming resources until they time out.
Affected: Python SDK (async + sync) and JS/TS SDK.
Steps to reproduce:
Call Sandbox.create(mcp={"invalid_server": {}}) with a config that causes mcp-gateway to fail
Observe the exception is raised
The sandbox remains running (visible via Sandbox.list())
Expected: The sandbox should be killed before the error is propagated.
Body:
When Sandbox.create() is called with an mcp config and the MCP gateway fails to start (non-zero exit code or exception from commands.run), the already-created sandbox is never killed. This leaves orphaned sandboxes consuming resources until they time out.
Affected: Python SDK (async + sync) and JS/TS SDK.
Steps to reproduce:
Call Sandbox.create(mcp={"invalid_server": {}}) with a config that causes mcp-gateway to fail
Observe the exception is raised
The sandbox remains running (visible via Sandbox.list())
Expected: The sandbox should be killed before the error is propagated.