Engel Nyst 590ebb6e47 Small fix and addition for token counting (#5550) 11 maanden geleden
..
README.md 3e49f0f827 Fix issue #5277: [Bug]: AttributeError: 'EventStreamRuntime' object has no attribute 'sid' if runtime_extra_deps is not None (#5330) 1 jaar geleden
__init__.py 6487175a31 refactored all relative paths to absolute paths (#3495) 1 jaar geleden
agent_session.py 2b06e4e5d0 [Feat] Custom MicroAgents. (#4983) 1 jaar geleden
conversation.py fd81670ba8 feat: add VSCode to OpenHands runtime and UI (#4745) 1 jaar geleden
manager.py a6d1a4c98f Fix: Redis listener attached at startup (#5516) 1 jaar geleden
session.py 590ebb6e47 Small fix and addition for token counting (#5550) 11 maanden geleden
session_init_data.py 590ebb6e47 Small fix and addition for token counting (#5550) 11 maanden geleden

README.md

Session Management

Socket.io is used as the underlying protocol for client server communication. This allows the event handlers in the code to be somewhat separate from the connection management - so brief connection 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) - this is distinct from the oh_event sent from the server to the client.
  • disconnect - Invoked when a connected client disconnects from the server.

Init

Each 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 new session should be started.

Disconnect

The (manager)[manager.py] manages connections and sessions. Each session may have zero or more connections associated with it, managed by invocations of INIT and disconnect. When a session no longer has any connections 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.)