Skip to content

πŸ™Œ OpenHands: AI-Driven Development

fix: Don't close runtime on error (#6549)

Ray Myers83724100e523
diff --git a/openhands/runtime/base.py b/openhands/runtime/base.py
index 4128c4cae6..779648f308 100644
--- a/openhands/runtime/base.py
+++ b/openhands/runtime/base.py
@@ -134,6 +134,10 @@ class Runtime(FileEditRuntimeMixin):
self.add_env_vars(self.config.sandbox.runtime_startup_env_vars)
def close(self) -> None:
+ """
+ This should only be called by conversation manager or closing the session.
+ If called for instance by error handling, it could prevent recovery.
+ """
pass
@classmethod
@@ -209,7 +213,6 @@ class Runtime(FileEditRuntimeMixin):
self.log('error', f'Unexpected error while running action: {error_message}')
self.log('error', f'Problematic action: {str(event)}')
self.send_error_message(err_id, error_message)
- self.close()
return
observation._cause = event.id # type: ignore[attr-defined]
diff --git a/openhands/runtime/impl/remote/remote_runtime.py b/openhands/runtime/impl/remote/remote_runtime.py
index ca72bb86b3..02e31fa364 100644
--- a/openhands/runtime/impl/remote/remote_runtime.py
+++ b/openhands/runtime/impl/remote/remote_runtime.py
@@ -341,8 +341,6 @@ class RemoteRuntime(ActionExecutionClient):
f'Runtime (ID={self.runtime_id}) is not yet ready. Status: {pod_status}'
)
elif pod_status in ('failed', 'unknown', 'crashloopbackoff'):
- # clean up the runtime
- self.close()
if pod_status == 'crashloopbackoff':
raise AgentRuntimeUnavailableError(
'Runtime crashed and is being restarted, potentially due to memory usage. Please try again.'