mirror of
https://github.com/OpenHands/OpenHands.git
synced 2025-12-26 05:48:36 +08:00
misc: make RemoteRuntime API timeout configurable (#6518)
Co-authored-by: Robert Brennan <accounts@rbren.io>
This commit is contained in:
parent
473fcae57e
commit
1a9971b1bf
@ -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'],
|
||||
|
||||
@ -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
|
||||
)
|
||||
|
||||
@ -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(
|
||||
|
||||
@ -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):
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user