π OpenHands: AI-Driven Development
Fix issue #5277: [Bug]: AttributeError: 'EventStreamRuntime' object has no attribute 'sid' if runtime_extra_deps is not None (#5330)
OpenHands3e49f0f82713
diff --git a/openhands/runtime/impl/eventstream/eventstream_runtime.py b/openhands/runtime/impl/eventstream/eventstream_runtime.pyindex 30f78f88a2..8cedcbe546 100644--- a/openhands/runtime/impl/eventstream/eventstream_runtime.py+++ b/openhands/runtime/impl/eventstream/eventstream_runtime.py@@ -188,12 +188,6 @@ class EventStreamRuntime(Runtime):# Buffer for container logsself.log_buffer: LogBuffer | None = None- if self.config.sandbox.runtime_extra_deps:- self.log(- 'debug',- f'Installing extra user-provided dependencies in the runtime image: {self.config.sandbox.runtime_extra_deps}',- )-self.init_base_runtime(config,event_stream,@@ -205,6 +199,13 @@ class EventStreamRuntime(Runtime):headless_mode,)+ # Log runtime_extra_deps after base class initialization so self.sid is available+ if self.config.sandbox.runtime_extra_deps:+ self.log(+ 'debug',+ f'Installing extra user-provided dependencies in the runtime image: {self.config.sandbox.runtime_extra_deps}',+ )+async def connect(self):self.send_status_message('STATUS$STARTING_RUNTIME')try:diff --git a/openhands/runtime/impl/remote/remote_runtime.py b/openhands/runtime/impl/remote/remote_runtime.pyindex 548e8a0ee2..4226bfef8f 100644--- a/openhands/runtime/impl/remote/remote_runtime.py+++ b/openhands/runtime/impl/remote/remote_runtime.py@@ -10,7 +10,6 @@ import requestsimport tenacityfrom openhands.core.config import AppConfig-from openhands.core.logger import openhands_logger as loggerfrom openhands.events import EventStreamfrom openhands.events.action import (BrowseInteractiveAction,diff --git a/openhands/server/session/README.md b/openhands/server/session/README.mdindex b367ba5864..12f7e270d6 100644--- a/openhands/server/session/README.md+++ b/openhands/server/session/README.md@@ -8,19 +8,19 @@ interruptions are recoverable.There are 3 main server side event handlers:* `connect` - Invoked when a new connection to the server is established. (This may be via http or WebSocket)-* `oh_action` - Invoked when a connected client sends an event (Such as `INIT` or a prompt for the Agent) -+* `oh_action` - Invoked when a connected client sends an event (Such as `INIT` or a prompt for the Agent) -this is distinct from the `oh_event` sent from the server to the client.* `disconnect` - Invoked when a connected client disconnects from the server.## InitEach connection has a unique id, and when initially established, is not associated with any session. An-`INIT` event must be sent to the server in order to attach a connection to a session. The `INIT` event-may optionally include a GitHub token and a token to connect to an existing session. (Which may be running-locally or may need to be hydrated). If no token is received as part of the init event, it is assumed a+`INIT` event must be sent to the server in order to attach a connection to a session. The `INIT` event+may optionally include a GitHub token and a token to connect to an existing session. (Which may be running+locally or may need to be hydrated). If no token is received as part of the init event, it is assumed anew session should be started.## Disconnect-The (manager)[manager.py] manages connections and sessions. Each session may have zero or more connections+The (manager)[manager.py] manages connections and sessions. Each session may have zero or more connectionsassociated with it, managed by invocations of `INIT` and disconnect. When a session no longer has anyconnections associated with it, after a set amount of time (determined by `config.sandbox.close_delay`),-the session and runtime are passivated (So will need to be rehydrated to continue.)+the session and runtime are passivated (So will need to be rehydrated to continue.)diff --git a/openhands/server/session/session.py b/openhands/server/session/session.pyindex e26d237a87..2b0ec8742c 100644--- a/openhands/server/session/session.py+++ b/openhands/server/session/session.py@@ -8,7 +8,6 @@ from openhands.core.config import AppConfigfrom openhands.core.const.guide_url import TROUBLESHOOTING_URLfrom openhands.core.logger import openhands_logger as loggerfrom openhands.core.schema import AgentState-from openhands.core.schema.action import ActionTypefrom openhands.core.schema.config import ConfigTypefrom openhands.events.action import MessageAction, NullActionfrom openhands.events.event import Event, EventSource@@ -23,7 +22,6 @@ from openhands.events.stream import EventStreamSubscriberfrom openhands.llm.llm import LLMfrom openhands.server.session.agent_session import AgentSessionfrom openhands.storage.files import FileStore-from openhands.utils.async_utils import call_coro_in_bg_threadROOM_KEY = 'room:{sid}'