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(cua-sandbox): honor Fleet request timeouts (#3381)
r33drichardsa925ffa25e6e
diff --git a/libs/python/cua-sandbox/cua_sandbox/transport/cyclops_http_client.py b/libs/python/cua-sandbox/cua_sandbox/transport/cyclops_http_client.pyindex ab7eeac680..fd80c880e7 100644--- a/libs/python/cua-sandbox/cua_sandbox/transport/cyclops_http_client.py+++ b/libs/python/cua-sandbox/cua_sandbox/transport/cyclops_http_client.py@@ -14,15 +14,21 @@ class CyclopsHttpClient(HttpClient):self._owns_client = client is Noneasync def execute(self, request: HttpRequest) -> HttpResponse:+ request_kwargs = {+ "headers": {header.name: header.value for header in request.headers},+ "content": request.body,+ }+ if request.timeout_secs is not None:+ request_kwargs["timeout"] = request.timeout_secs+try:response = await self._client.request(request.method,request.url,- headers={header.name: header.value for header in request.headers},- content=request.body,+ **request_kwargs,)except httpx.TransportError as error:- raise HttpError.Transport(str(error)) from error+ raise HttpError.Transport(str(error) or type(error).__name__) from errorreturn HttpResponse(status=response.status_code,headers=[diff --git a/libs/python/cua-sandbox/tests/test_cyclops_http_client.py b/libs/python/cua-sandbox/tests/test_cyclops_http_client.pynew file mode 100644index 0000000000..728356bec3--- /dev/null+++ b/libs/python/cua-sandbox/tests/test_cyclops_http_client.py@@ -0,0 +1,66 @@+from __future__ import annotations++from typing import Any++import httpx+import pytest+from cua_sandbox.transport.cyclops_http_client import CyclopsHttpClient+from fleet_sdk import HttpError, HttpRequest+++class RecordingClient:+ def __init__(self, response: httpx.Response | Exception) -> None:+ self.response = response+ self.calls: list[tuple[str, str, dict[str, Any]]] = []++ async def request(self, method: str, url: str, **kwargs: Any) -> httpx.Response:+ self.calls.append((method, url, kwargs))+ if isinstance(self.response, Exception):+ raise self.response+ return self.response+++def fleet_request(timeout_secs: int | None) -> HttpRequest:+ return HttpRequest(+ method="POST",+ url="https://fleet.example/api/svc/ns/computer-server/cmd",+ headers=[],+ body=b"{}",+ timeout_secs=timeout_secs,+ )+++async def test_execute_forwards_per_request_timeout_to_httpx() -> None:+ response = httpx.Response(200, content=b"ok")+ client = RecordingClient(response)++ result = await CyclopsHttpClient(client).execute(fleet_request(120))++ assert result.status == 200+ assert client.calls == [+ (+ "POST",+ "https://fleet.example/api/svc/ns/computer-server/cmd",+ {"headers": {}, "content": b"{}", "timeout": 120},+ )+ ]+++async def test_execute_uses_shared_client_default_without_request_timeout() -> None:+ client = RecordingClient(httpx.Response(200, content=b"ok"))++ await CyclopsHttpClient(client).execute(fleet_request(None))++ assert "timeout" not in client.calls[0][2]+++async def test_execute_reports_transport_error_type_when_message_is_empty() -> None:+ client = RecordingClient(httpx.ReadTimeout(""))++ with pytest.raises(HttpError.Transport) as raised:+ await CyclopsHttpClient(client).execute(fleet_request(120))++ assert raised.value.reason == "ReadTimeout"