π OpenHands: AI-Driven Development
misc: make RemoteRuntime API timeout configurable (#6518)
Xingyao Wang1a9971b1bfb4
diff --git a/evaluation/benchmarks/swe_bench/run_infer.py b/evaluation/benchmarks/swe_bench/run_infer.pyindex 959576ffcd..e1a1764f21 100644--- a/evaluation/benchmarks/swe_bench/run_infer.py+++ b/evaluation/benchmarks/swe_bench/run_infer.py@@ -139,6 +139,7 @@ def get_config(remote_runtime_api_url=os.environ.get('SANDBOX_REMOTE_RUNTIME_API_URL'),keep_runtime_alive=False,remote_runtime_init_timeout=3600,+ remote_runtime_api_timeout=120,remote_runtime_resource_factor=get_instance_resource_factor(dataset_name=metadata.dataset,instance_id=instance['instance_id'],diff --git a/openhands/core/config/sandbox_config.py b/openhands/core/config/sandbox_config.pyindex bd3d81f559..55ff384e0c 100644--- a/openhands/core/config/sandbox_config.py+++ b/openhands/core/config/sandbox_config.py@@ -14,6 +14,7 @@ class SandboxConfig(BaseModel):user_id: The user ID for the sandbox.timeout: The timeout for the default sandbox action execution.remote_runtime_init_timeout: The timeout for the remote runtime to start.+ remote_runtime_api_timeout: The timeout for the remote runtime API requests.enable_auto_lint: Whether to enable auto-lint.use_host_network: Whether to use the host network.initialize_plugins: Whether to initialize plugins.@@ -49,6 +50,7 @@ class SandboxConfig(BaseModel):user_id: int = Field(default=os.getuid() if hasattr(os, 'getuid') else 1000)timeout: int = Field(default=120)remote_runtime_init_timeout: int = Field(default=180)+ remote_runtime_api_timeout: int = Field(default=10)enable_auto_lint: bool = Field(default=False # once enabled, OpenHands would lint files after editing)diff --git a/openhands/runtime/impl/remote/remote_runtime.py b/openhands/runtime/impl/remote/remote_runtime.pyindex 57d8e8def8..ca72bb86b3 100644--- a/openhands/runtime/impl/remote/remote_runtime.py+++ b/openhands/runtime/impl/remote/remote_runtime.py@@ -381,6 +381,7 @@ class RemoteRuntime(ActionExecutionClient):def _send_runtime_api_request(self, method, url, **kwargs):try:+ kwargs['timeout'] = self.config.sandbox.remote_runtime_api_timeoutreturn send_request(self.session, method, url, **kwargs)except requests.Timeout:self.log(diff --git a/tests/unit/test_iteration_limit.py b/tests/unit/test_iteration_limit.pyindex 4520231a0d..29108387e7 100644--- a/tests/unit/test_iteration_limit.py+++ b/tests/unit/test_iteration_limit.py@@ -7,6 +7,7 @@ from openhands.core.schema import AgentStatefrom openhands.events import EventStreamfrom openhands.events.action import MessageActionfrom openhands.events.event import EventSource+from openhands.llm.metrics import Metricsclass DummyAgent:@@ -15,7 +16,7 @@ class DummyAgent:self.llm = type('DummyLLM',(),- {'metrics': type('DummyMetrics', (), {'merge': lambda x: None})()},+ {'metrics': Metrics()},)()def reset(self):