chore(server): rename Session to WebSession (#10565)

This commit is contained in:
Engel Nyst 2025-09-04 16:49:54 +02:00 committed by GitHub
parent 55a6bbd9a4
commit 81d6341f9d
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 34 additions and 5 deletions

View File

@ -34,7 +34,7 @@ from openhands.server.data_models.agent_loop_info import AgentLoopInfo
from openhands.server.monitoring import MonitoringListener
from openhands.server.session.conversation import ServerConversation
from openhands.server.session.conversation_init_data import ConversationInitData
from openhands.server.session.session import Session
from openhands.server.session.session import WebSession as Session
from openhands.storage.conversation.conversation_store import ConversationStore
from openhands.storage.data_models.conversation_metadata import ConversationMetadata
from openhands.storage.data_models.conversation_status import ConversationStatus

View File

@ -23,7 +23,7 @@ from openhands.server.data_models.agent_loop_info import AgentLoopInfo
from openhands.server.monitoring import MonitoringListener
from openhands.server.session.agent_session import WAIT_TIME_BEFORE_CLOSE, AgentSession
from openhands.server.session.conversation import ServerConversation
from openhands.server.session.session import Session
from openhands.server.session.session import WebSession as Session
from openhands.storage.conversation.conversation_store import ConversationStore
from openhands.storage.data_models.conversation_metadata import ConversationMetadata
from openhands.storage.data_models.conversation_status import ConversationStatus

View File

@ -1,3 +1,6 @@
from openhands.server.session.session import Session
# Backward-compatible import for the web server-bound session wrapper.
# The canonical name is WebSession; Session is an alias to be removed later.
from openhands.server.session.session import WebSession
from openhands.server.session.session import WebSession as Session
__all__ = ['Session']
__all__ = ['WebSession', 'Session']

View File

@ -37,7 +37,28 @@ from openhands.storage.data_models.settings import Settings
from openhands.storage.files import FileStore
class Session:
class WebSession:
"""Web server-bound session wrapper.
This was previously named `Session`. We keep `Session` as a compatibility alias
(see openhands.server.session.__init__) so downstream imports/tests continue to
work. The class manages a single web client connection and orchestrates the
AgentSession lifecycle for that conversation.
Attributes:
sid: Stable conversation id across transports.
sio: Socket.IO server used to emit events to the web client.
last_active_ts: Unix timestamp of last successful send.
is_alive: Whether the web connection is still alive.
agent_session: Core agent session coordinating runtime/LLM.
loop: The asyncio loop associated with the session.
config: Effective OpenHands configuration for this conversation.
llm_registry: Registry responsible for LLM access and retry hooks.
file_store: File storage interface for this conversation.
user_id: Optional multi-tenant user identifier.
logger: Logger with session context.
"""
sid: str
sio: socketio.AsyncServer | None
last_active_ts: int = 0
@ -427,3 +448,8 @@ class Session:
asyncio.run_coroutine_threadsafe(
self._send_status_message(msg_type, runtime_status, message), self.loop
)
# Backward-compatible alias for external imports that still reference
# openhands.server.session.session import Session
Session = WebSession