Feat socket io
Using SocketIO as the Underlying Communication Protocol
- [X] Include this change in the Release Notes. If checked, you must provide an end-user friendly description for your change below
Migration / Refactor to use SocketIO as the communication protocol instead of raw Websockets
- Better Error Tolerance
- Better Clusterability (Using Redis)
Testing Scenarios:
Starting a new session should open a single websocket
Refreshing the page should allow the session to continue uninterrupted (I refreshed the page then asked a follow on question):
Interrupting the socket without refreshing the page should allow the session to continue uninterrupted (You can see in the screenshot that I used the developer console to close the socket, and a new one instantly opened to replace it. I asked a follow up question with no issue):
Many of the Use cases for this PR (Particularly related to Redis are mostly applicable in the SAAS environment, where Pods may cease to exist mid session and we want to minimize user disruption. The logic when dealing with multiple pods is more complex than with a single pod!
Fixes https://github.com/All-Hands-AI/OpenHands/issues/5151
To run this PR locally, use the following command:
docker run -it --rm -p 3000:3000 -v /var/run/docker.sock:/var/run/docker.sock --add-host host.docker.internal:host-gateway -e SANDBOX_RUNTIME_CONTAINER_IMAGE=docker.all-hands.dev/all-hands-ai/runtime:cecac3f-nikolaik --name openhands-app-cecac3f docker.all-hands.dev/all-hands-ai/openhands:cecac3f
Will this make https://github.com/All-Hands-AI/OpenHands/issues/5019 easier to implement by decoupling the Session from the websocket?
Will this make https://github.com/All-Hands-AI/OpenHands/issues/5019 easier to implement by decoupling the Session from the websocket?
I don't think so. We'll have to think carefully about that one--the agent loop will continue running in perpetuity if we don't explicitly close it on some event
the agent loop will continue running in perpetuity if we don't explicitly close it on some event
I think it will be closed by a timeout event, with a configurable idle time of say N minutes (in our setup, we would close out the session after many hours)
Heck, when the EventStreamRuntime is instantiated, it can just inject an async event after sleeping N minutes to terminate itself into the event loop.
E.g.
asyncio.sleep(...)
self.close()
the agent loop will continue running in perpetuity if we don't explicitly close it on some eventI think it will be closed by a timeout event, with a configurable idle time of say N minutes (in our setup, we would close out the session after many hours)Heck, when the
EventStreamRuntimeis instantiated, it can just inject an async event after sleeping N minutes to terminate itself into the event loop.E.g.
asyncio.sleep(...) self.close()
I'll update the PR to make this value configurable - so that there is a delay before the runtime is closed out.