Skip to content

Fix - Make Remote runtime use /start for both new and resume #8564

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 3 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 19 additions & 25 deletions openhands/runtime/impl/remote/remote_runtime.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,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
Expand Down Expand Up @@ -120,40 +124,30 @@ 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.'
)
assert self.runtime_url is not 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:
Expand Down
Loading