@@ -136,19 +136,23 @@ protected void handleTextMessage(WebSocketSession session, TextMessage message)
136136 if (uri != null ) {
137137 Map <String , String > queryParams = parseQueryParams (uri .getQuery ());
138138 String sessionId = queryParams .get ("sessionId" );
139+ String userId = queryParams .get ("userId" );
139140
140141 var websocky = userCommunicationService .getSession (sessionId );
141142
143+
142144 if (sessionId != null && websocky .isPresent ()) {
143145 var websocketCommunication = websocky .get ();
146+ websocketCommunication .setUserId (userId );
144147 if (null == websocketCommunication .getAgentExecutionContextDTO ().getAgentContext ()){
145148 log .info ("Loading agent context for session ID: {} is null ? {}" , sessionId ,
146149 agentExecutionService .getExecutionContextDTO ( chatAgent .getAgentExecution ().getExecutionId () ).getAgentContext ()==null );
147150 websocketCommunication .getAgentExecutionContextDTO ().setAgentContext (
148151 agentExecutionService .getExecutionContextDTO ( chatAgent .getAgentExecution ().getExecutionId () ).getAgentContext ()
149152 );
150153 }
151- log .info ("Received message from session ID: {}" , sessionId , websocketCommunication .getUniqueIdentifier ());
154+ log .info ("Received message from session ID: {}, userId {}" , sessionId ,
155+ websocketCommunication .getUniqueIdentifier (), userId );
152156 // Handle the message (e.g., process or respond)
153157
154158
@@ -521,9 +525,7 @@ protected void handleTextMessage(WebSocketSession session, TextMessage message)
521525 memoryMeta .get ("value" ) : memoryMeta ;
522526
523527 // Add userId to markings for privacy scoping if userId is available
524- String userId = chatAgent .getAgentExecution ().getUser () != null
525- ? chatAgent .getAgentExecution ().getUser ().getUserId ()
526- : null ;
528+
527529 String enhancedMarkings ;
528530 if (userId != null && !userId .isEmpty ()) {
529531 enhancedMarkings = markings != null
@@ -574,10 +576,7 @@ protected void handleTextMessage(WebSocketSession session, TextMessage message)
574576 JsonNode value = memoryMeta .has ("value" ) ?
575577 memoryMeta .get ("value" ) : memoryMeta ;
576578
577- // Add userId to markings for privacy scoping if userId is available
578- String userId = chatAgent .getAgentExecution ().getUser () != null
579- ? chatAgent .getAgentExecution ().getUser ().getUserId ()
580- : null ;
579+
581580 String enhancedMarkings ;
582581 if (userId != null && !userId .isEmpty ()) {
583582 enhancedMarkings = markings != null
0 commit comments