misc: make RemoteRuntime API timeout configurable (#6518)

Co-authored-by: Robert Brennan <accounts@rbren.io>
This commit is contained in:
Xingyao Wang 2025-01-29 17:30:18 -05:00 committed by GitHub
parent 473fcae57e
commit 1a9971b1bf
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 6 additions and 1 deletions

View File

@ -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'],

View File

@ -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
)

View File

@ -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_timeout
return send_request(self.session, method, url, **kwargs)
except requests.Timeout:
self.log(

View File

@ -7,6 +7,7 @@ from openhands.core.schema import AgentState
from openhands.events import EventStream
from openhands.events.action import MessageAction
from openhands.events.event import EventSource
from openhands.llm.metrics import Metrics
class DummyAgent:
@ -15,7 +16,7 @@ class DummyAgent:
self.llm = type(
'DummyLLM',
(),
{'metrics': type('DummyMetrics', (), {'merge': lambda x: None})()},
{'metrics': Metrics()},
)()
def reset(self):