From ec3982fc784cea7991bdc9c90e8ee5d7e7d1a330 Mon Sep 17 00:00:00 2001 From: Ray Myers Date: Sat, 17 May 2025 16:57:16 -0500 Subject: [PATCH] Fix - Remote runtime uses /start for both new and resume --- .../runtime/impl/remote/remote_runtime.py | 44 ++++++++----------- 1 file changed, 19 insertions(+), 25 deletions(-) diff --git a/openhands/runtime/impl/remote/remote_runtime.py b/openhands/runtime/impl/remote/remote_runtime.py index 5d5324f1b768..48901b0c5224 100644 --- a/openhands/runtime/impl/remote/remote_runtime.py +++ b/openhands/runtime/impl/remote/remote_runtime.py @@ -32,7 +32,11 @@ class RemoteRuntime(ActionExecutionClient): - """This runtime will connect to a remote oh-runtime-client.""" + """ + This runtime will connect to a remote oh-runtime-client. + + The attach_to_existing option is ignored, `connect` will always resume if possible. + """ port: int = 60000 # default port for the remote runtime client runtime_id: str | None = None @@ -116,28 +120,20 @@ async def connect(self) -> None: self._runtime_initialized = True def _start_or_attach_to_runtime(self) -> None: - existing_runtime = self._check_existing_runtime() - if existing_runtime: - self.log('debug', f'Using existing runtime with ID: {self.runtime_id}') - elif self.attach_to_existing: - raise AgentRuntimeNotFoundError( - f'Could not find existing runtime for SID: {self.sid}' + self.send_status_message('STATUS$STARTING_CONTAINER') + if self.config.sandbox.runtime_container_image is None: + self.log( + 'info', + f'Building remote runtime with base image: {self.config.sandbox.base_container_image}', ) + self._build_runtime() else: - self.send_status_message('STATUS$STARTING_CONTAINER') - if self.config.sandbox.runtime_container_image is None: - self.log( - 'info', - f'Building remote runtime with base image: {self.config.sandbox.base_container_image}', - ) - self._build_runtime() - else: - self.log( - 'info', - f'Starting remote runtime with image: {self.config.sandbox.runtime_container_image}', - ) - self.container_image = self.config.sandbox.runtime_container_image - self._start_runtime() + self.log( + 'info', + f'Starting remote runtime with image: {self.config.sandbox.runtime_container_image}', + ) + self.container_image = self.config.sandbox.runtime_container_image + self._start_runtime() assert self.runtime_id is not None, ( 'Runtime ID is not set. This should never happen.' ) @@ -145,11 +141,9 @@ def _start_or_attach_to_runtime(self) -> None: 'Runtime URL is not set. This should never happen.' ) self.send_status_message('STATUS$WAITING_FOR_CLIENT') - if not self.attach_to_existing: - self.log('info', 'Waiting for runtime to be alive...') + self.log('info', 'Waiting for runtime to be alive...') self._wait_until_alive() - if not self.attach_to_existing: - self.log('info', 'Runtime is ready.') + self.log('info', 'Runtime is ready.') self.send_status_message(' ') def _check_existing_runtime(self) -> bool: