π OpenHands: AI-Driven Development
Fix bash timeout issue caused by interactive git clone prompts (#9148)
Graham Neubigcbe32a1a12a2
diff --git a/openhands/runtime/base.py b/openhands/runtime/base.pyindex 658c76c652..2054e208e1 100644--- a/openhands/runtime/base.py+++ b/openhands/runtime/base.py@@ -706,7 +706,9 @@ fi# Get authenticated URL and do a shallow clone (--depth 1) for efficiencyremote_url = self._get_authenticated_git_url(org_openhands_repo)- clone_cmd = f'git clone --depth 1 {remote_url} {org_repo_dir}'+ clone_cmd = (+ f'GIT_TERMINAL_PROMPT=0 git clone --depth 1 {remote_url} {org_repo_dir}'+ )action = CmdRunAction(command=clone_cmd)obs = self.run_action(action)diff --git a/openhands/runtime/impl/daytona/daytona_runtime.py b/openhands/runtime/impl/daytona/daytona_runtime.pyindex 3087915a54..b9e3302e93 100644--- a/openhands/runtime/impl/daytona/daytona_runtime.py+++ b/openhands/runtime/impl/daytona/daytona_runtime.py@@ -13,6 +13,7 @@ from daytona_sdk import (from openhands.core.config.openhands_config import OpenHandsConfigfrom openhands.events.stream import EventStream+from openhands.integrations.provider import PROVIDER_TOKEN_TYPEfrom openhands.runtime.impl.action_execution.action_execution_client import (ActionExecutionClient,)@@ -42,6 +43,8 @@ class DaytonaRuntime(ActionExecutionClient):status_callback: Callable | None = None,attach_to_existing: bool = False,headless_mode: bool = True,+ user_id: str | None = None,+ git_provider_tokens: PROVIDER_TOKEN_TYPE | None = None,):assert config.daytona_api_key, 'Daytona API key is required'@@ -74,6 +77,8 @@ class DaytonaRuntime(ActionExecutionClient):status_callback,attach_to_existing,headless_mode,+ user_id,+ git_provider_tokens,)def _get_workspace(self) -> Workspace | None:diff --git a/openhands/runtime/impl/docker/docker_runtime.py b/openhands/runtime/impl/docker/docker_runtime.pyindex 9553933475..bac1ef1f23 100644--- a/openhands/runtime/impl/docker/docker_runtime.py+++ b/openhands/runtime/impl/docker/docker_runtime.py@@ -17,6 +17,7 @@ from openhands.core.exceptions import (from openhands.core.logger import DEBUG, DEBUG_RUNTIMEfrom openhands.core.logger import openhands_logger as loggerfrom openhands.events import EventStream+from openhands.integrations.provider import PROVIDER_TOKEN_TYPEfrom openhands.runtime.builder import DockerRuntimeBuilderfrom openhands.runtime.impl.action_execution.action_execution_client import (ActionExecutionClient,@@ -86,6 +87,8 @@ class DockerRuntime(ActionExecutionClient):status_callback: Callable | None = None,attach_to_existing: bool = False,headless_mode: bool = True,+ user_id: str | None = None,+ git_provider_tokens: PROVIDER_TOKEN_TYPE | None = None,main_module: str = DEFAULT_MAIN_MODULE,):if not DockerRuntime._shutdown_listener_id:@@ -132,6 +135,8 @@ class DockerRuntime(ActionExecutionClient):status_callback,attach_to_existing,headless_mode,+ user_id,+ git_provider_tokens,)# Log runtime_extra_deps after base class initialization so self.sid is availablediff --git a/openhands/runtime/impl/e2b/e2b_runtime.py b/openhands/runtime/impl/e2b/e2b_runtime.pyindex 2cf20f3ff9..29a0249e22 100644--- a/openhands/runtime/impl/e2b/e2b_runtime.py+++ b/openhands/runtime/impl/e2b/e2b_runtime.py@@ -12,29 +12,42 @@ from openhands.events.observation import (Observation,)from openhands.events.stream import EventStream-from openhands.runtime.base import Runtime+from openhands.integrations.provider import PROVIDER_TOKEN_TYPE+from openhands.runtime.impl.action_execution.action_execution_client import (+ ActionExecutionClient,+)from openhands.runtime.impl.e2b.filestore import E2BFileStorefrom openhands.runtime.impl.e2b.sandbox import E2BSandboxfrom openhands.runtime.plugins import PluginRequirementfrom openhands.runtime.utils.files import insert_lines, read_lines-class E2BRuntime(Runtime):+class E2BRuntime(ActionExecutionClient):def __init__(self,config: OpenHandsConfig,event_stream: EventStream,sid: str = 'default',plugins: list[PluginRequirement] | None = None,- sandbox: E2BSandbox | None = None,+ env_vars: dict[str, str] | None = None,status_callback: Callable | None = None,+ attach_to_existing: bool = False,+ headless_mode: bool = True,+ user_id: str | None = None,+ git_provider_tokens: PROVIDER_TOKEN_TYPE | None = None,+ sandbox: E2BSandbox | None = None,):super().__init__(config,event_stream,sid,plugins,- status_callback=status_callback,+ env_vars,+ status_callback,+ attach_to_existing,+ headless_mode,+ user_id,+ git_provider_tokens,)if sandbox is None:self.sandbox = E2BSandbox()diff --git a/openhands/runtime/impl/local/local_runtime.py b/openhands/runtime/impl/local/local_runtime.pyindex 835a87ba5c..651c8b0e82 100644--- a/openhands/runtime/impl/local/local_runtime.py+++ b/openhands/runtime/impl/local/local_runtime.py@@ -25,6 +25,7 @@ from openhands.events.observation import (Observation,)from openhands.events.serialization import event_to_dict, observation_from_dict+from openhands.integrations.provider import PROVIDER_TOKEN_TYPEfrom openhands.runtime.impl.action_execution.action_execution_client import (ActionExecutionClient,)@@ -145,6 +146,8 @@ class LocalRuntime(ActionExecutionClient):status_callback: Callable[[str, str, str], None] | None = None,attach_to_existing: bool = False,headless_mode: bool = True,+ user_id: str | None = None,+ git_provider_tokens: PROVIDER_TOKEN_TYPE | None = None,) -> None:self.is_windows = sys.platform == 'win32'if self.is_windows:@@ -194,6 +197,8 @@ class LocalRuntime(ActionExecutionClient):status_callback,attach_to_existing,headless_mode,+ user_id,+ git_provider_tokens,)# If there is an API key in the environment we use this in requests to the runtimediff --git a/openhands/runtime/impl/modal/modal_runtime.py b/openhands/runtime/impl/modal/modal_runtime.pyindex ac0444227c..6ce8277156 100644--- a/openhands/runtime/impl/modal/modal_runtime.py+++ b/openhands/runtime/impl/modal/modal_runtime.py@@ -9,6 +9,7 @@ import tenacityfrom openhands.core.config import OpenHandsConfigfrom openhands.events import EventStream+from openhands.integrations.provider import PROVIDER_TOKEN_TYPEfrom openhands.runtime.impl.action_execution.action_execution_client import (ActionExecutionClient,)@@ -53,6 +54,8 @@ class ModalRuntime(ActionExecutionClient):status_callback: Callable | None = None,attach_to_existing: bool = False,headless_mode: bool = True,+ user_id: str | None = None,+ git_provider_tokens: PROVIDER_TOKEN_TYPE | None = None,):assert config.modal_api_token_id, 'Modal API token id is required'assert config.modal_api_token_secret, 'Modal API token secret is required'@@ -100,6 +103,8 @@ class ModalRuntime(ActionExecutionClient):status_callback,attach_to_existing,headless_mode,+ user_id,+ git_provider_tokens,)async def connect(self):diff --git a/openhands/runtime/impl/runloop/runloop_runtime.py b/openhands/runtime/impl/runloop/runloop_runtime.pyindex 9de58a4404..00b684d489 100644--- a/openhands/runtime/impl/runloop/runloop_runtime.py+++ b/openhands/runtime/impl/runloop/runloop_runtime.py@@ -9,6 +9,7 @@ from runloop_api_client.types.shared_params import LaunchParametersfrom openhands.core.config import OpenHandsConfigfrom openhands.core.logger import openhands_logger as loggerfrom openhands.events import EventStream+from openhands.integrations.provider import PROVIDER_TOKEN_TYPEfrom openhands.runtime.impl.action_execution.action_execution_client import (ActionExecutionClient,)@@ -36,6 +37,8 @@ class RunloopRuntime(ActionExecutionClient):status_callback: Callable | None = None,attach_to_existing: bool = False,headless_mode: bool = True,+ user_id: str | None = None,+ git_provider_tokens: PROVIDER_TOKEN_TYPE | None = None,):assert config.runloop_api_key is not None, 'Runloop API key is required'self.devbox: DevboxView | None = None@@ -53,6 +56,8 @@ class RunloopRuntime(ActionExecutionClient):status_callback,attach_to_existing,headless_mode,+ user_id,+ git_provider_tokens,)# Buffer for container logsself._vscode_url: str | None = Nonediff --git a/openhands/server/session/agent_session.py b/openhands/server/session/agent_session.pyindex 2441e77c5d..add7b2a75f 100644--- a/openhands/server/session/agent_session.py+++ b/openhands/server/session/agent_session.py@@ -366,6 +366,7 @@ class AgentSession:headless_mode=False,attach_to_existing=False,env_vars=env_vars,+ git_provider_tokens=git_provider_tokens,)# FIXME: this sleep is a terrible hack.