MCPcopy
hub / github.com/OpenBMB/ChatDev / ensure_known_session

Function ensure_known_session

server/state.py:24–37  ·  view source on GitHub ↗

Return the WebSocket manager if the session is connected or known.

(session_id: str, *, require_connection: bool = False)

Source from the content-addressed store, hash-verified

22
23
24def ensure_known_session(session_id: str, *, require_connection: bool = False) -> WebSocketManager:
25 """Return the WebSocket manager if the session is connected or known."""
26
27 manager = get_websocket_manager()
28 if not session_id:
29 raise ValidationError("Session not connected", details={"session_id": session_id})
30
31 if session_id in manager.active_connections:
32 return manager
33
34 if not require_connection and manager.session_store.has_session(session_id):
35 return manager
36
37 raise ValidationError("Session not connected", details={"session_id": session_id})

Callers 4

execute_workflowFunction · 0.90
upload_attachmentFunction · 0.90
list_attachmentsFunction · 0.90
execute_batchFunction · 0.90

Calls 3

ValidationErrorClass · 0.90
get_websocket_managerFunction · 0.85
has_sessionMethod · 0.80

Tested by

no test coverage detected