@@ -124,6 +124,15 @@ public void ProcessRawMessage(string json)
124124 method ! . Invoke ( _client , new object [ ] { json } ) ;
125125 }
126126
127+ public ChatHistoryInfo ParseChatHistoryPayload ( string payloadJson , string sessionKey = "main" )
128+ {
129+ using var document = JsonDocument . Parse ( payloadJson ) ;
130+ var method = typeof ( OpenClawGatewayClient ) . GetMethod (
131+ "ParseChatHistory" ,
132+ System . Reflection . BindingFlags . NonPublic | System . Reflection . BindingFlags . Static ) ;
133+ return ( ChatHistoryInfo ) method ! . Invoke ( null , new object [ ] { document . RootElement . Clone ( ) , sessionKey } ) ! ;
134+ }
135+
127136 public long ExtractChatTimestampMs ( string payloadJson )
128137 {
129138 using var document = JsonDocument . Parse ( payloadJson ) ;
@@ -845,6 +854,81 @@ public void ProcessRawMessage_SessionMessageWithContentBlocks_EmitsChatMessage()
845854 Assert . Equal ( 1781631280633 , received . Ts ) ;
846855 }
847856
857+ [ Fact ]
858+ public void ProcessRawMessage_SessionMessageAssistantNoReply_DropsFrame ( )
859+ {
860+ var helper = new GatewayClientTestHelper ( ) ;
861+ ChatMessageInfo ? received = null ;
862+ OpenClawNotification ? notification = null ;
863+ helper . Client . ChatMessageReceived += ( _ , message ) => received = message ;
864+ helper . Client . NotificationReceived += ( _ , value ) => notification = value ;
865+
866+ helper . ProcessRawMessage ( """
867+ {
868+ "type": "event",
869+ "event": "session.message",
870+ "payload": {
871+ "sessionKey": "main",
872+ "message": {
873+ "role": "assistant",
874+ "content": " NO_REPLY\n",
875+ "timestamp": 1781631280633
876+ },
877+ "state": "final"
878+ }
879+ }
880+ """ ) ;
881+
882+ Assert . Null ( received ) ;
883+ Assert . Null ( notification ) ;
884+ }
885+
886+ [ Fact ]
887+ public void ProcessRawMessage_SessionMessageUserNoReply_IsNotDropped ( )
888+ {
889+ var helper = new GatewayClientTestHelper ( ) ;
890+ ChatMessageInfo ? received = null ;
891+ helper . Client . ChatMessageReceived += ( _ , message ) => received = message ;
892+
893+ helper . ProcessRawMessage ( """
894+ {
895+ "type": "event",
896+ "event": "session.message",
897+ "payload": {
898+ "sessionKey": "main",
899+ "message": {
900+ "role": "user",
901+ "content": "NO_REPLY",
902+ "timestamp": 1781631280633
903+ },
904+ "state": "final"
905+ }
906+ }
907+ """ ) ;
908+
909+ Assert . NotNull ( received ) ;
910+ Assert . Equal ( "user" , received ! . Role ) ;
911+ Assert . Equal ( "NO_REPLY" , received . Text ) ;
912+ }
913+
914+ [ Fact ]
915+ public void ParseChatHistoryPayload_AssistantNoReply_DropsTranscriptEntry ( )
916+ {
917+ var helper = new GatewayClientTestHelper ( ) ;
918+
919+ var history = helper . ParseChatHistoryPayload ( """
920+ {
921+ "messages": [
922+ { "role": "user", "content": "before", "timestamp": 1 },
923+ { "role": "assistant", "content": "NO_REPLY", "timestamp": 2 },
924+ { "role": "assistant", "content": "visible reply", "timestamp": 3 }
925+ ]
926+ }
927+ """ ) ;
928+
929+ Assert . Equal ( [ "before" , "visible reply" ] , history . Messages . Select ( m => m . Text ) . ToArray ( ) ) ;
930+ }
931+
848932 [ Fact ]
849933 public void ProcessRawMessage_SessionMessageWithMalformedMessage_DropsFrame ( )
850934 {
0 commit comments