@@ -1167,10 +1167,18 @@ ChatTimelineState ApplyAndCaptureMeta(ChatTimelineState s, ChatEvent e, ChatEntr
11671167 var attachmentMatcher = CreateAttachmentMetaMatcher ( history . SessionId , threadId ) ;
11681168 var pendingUnkeyedToolCalls = new Queue < string > ( ) ;
11691169 var syntheticToolCallSequence = 0 ;
1170+ ChatMessageInfo ? suppressedAbortedAssistant = null ;
11701171
11711172 foreach ( var replayPart in ChatHistoryReplayProjection . Project ( ordered ) )
11721173 {
11731174 var msg = replayPart . Message ;
1175+ if ( suppressedAbortedAssistant is not null )
1176+ {
1177+ if ( ReferenceEquals ( suppressedAbortedAssistant , msg ) )
1178+ continue ;
1179+ suppressedAbortedAssistant = null ;
1180+ }
1181+
11741182 var roleLower = msg . Role ? . ToLowerInvariant ( ) ?? "" ;
11751183 var rawText = replayPart . Text ;
11761184 var ts = msg . Ts > 0
@@ -1195,9 +1203,7 @@ ChatTimelineState ApplyAndCaptureMeta(ChatTimelineState s, ChatEvent e, ChatEntr
11951203 var text = TruncateForChatEntry ( EscapeUntrustedAttachmentMarkerLines ( rawText ) ) ;
11961204 if ( roleLower == "user" )
11971205 text = RehydrateAttachmentMarkers ( attachmentMatcher , text , msg . Ts ) ;
1198-
11991206 var hasStructuredToolContent = replayPart . ToolContent . Count > 0 ;
1200- if ( string . IsNullOrEmpty ( text ) && ! hasStructuredToolContent ) continue ;
12011207
12021208 // Check if this user message was aborted (persisted __openclaw.id match)
12031209 if ( roleLower == "user" )
@@ -1214,18 +1220,30 @@ ChatTimelineState ApplyAndCaptureMeta(ChatTimelineState s, ChatEvent e, ChatEntr
12141220 ! string . Equals ( msg . StopReason , "toolUse" , StringComparison . OrdinalIgnoreCase ) &&
12151221 ! string . Equals ( msg . StopReason , "end_turn" , StringComparison . OrdinalIgnoreCase ) ;
12161222
1217- bool shouldMarkAborted = replayPart . IsFirstTextPart
1218- && ( ( roleLower == "assistant" && nextAssistantIsAborted ) || gatewayAborted ) ;
1219- if ( roleLower == "assistant" && replayPart . IsFirstTextPart )
1223+ var isFirstAssistantPart = roleLower == "assistant" && replayPart . IsFirstPart ;
1224+ var shouldSuppressAssistant = isFirstAssistantPart
1225+ && ( nextAssistantIsAborted || gatewayAborted ) ;
1226+ if ( isFirstAssistantPart )
12201227 nextAssistantIsAborted = false ;
1221- if ( gatewayAborted && ! replayPart . IsFirstTextPart && ! string . IsNullOrEmpty ( text ) )
1228+ if ( shouldSuppressAssistant )
1229+ {
1230+ Logger . Debug ( "[ChatHistory] → routed: ABORTED (response was stopped)" ) ;
1231+ rebuilt = ApplyAndCaptureMeta (
1232+ rebuilt ,
1233+ new ChatStatusEvent ( "Response was stopped" , ChatTone . Warning ) ,
1234+ msgMeta ) ;
1235+ rebuilt = ChatTimelineReducer . Apply ( rebuilt , new ChatTurnEndEvent ( ) ) ;
1236+ suppressedAbortedAssistant = msg ;
12221237 continue ;
1238+ }
1239+
1240+ if ( string . IsNullOrEmpty ( text ) && ! hasStructuredToolContent ) continue ;
12231241
12241242 // Diagnostic: log shape (role + length + heuristic flags) only.
12251243 // Never log the message text — see HIGH 4 logging audit.
12261244 var isFlat = NativeToolProjector . LooksLikeFlattenedToolOutput ( text ) ;
12271245 var isSys = NativeToolProjector . LooksLikeSystemControlNote ( text ) ;
1228- Logger . Debug ( $ "[ChatHistory] role='{ roleLower } ' len={ text . Length } flat={ isFlat } sys={ isSys } aborted= { shouldMarkAborted } ") ;
1246+ Logger . Debug ( $ "[ChatHistory] role='{ roleLower } ' len={ text . Length } flat={ isFlat } sys={ isSys } ") ;
12291247
12301248 if ( ! string . IsNullOrEmpty ( text ) )
12311249 {
@@ -1277,18 +1295,6 @@ ChatTimelineState ApplyAndCaptureMeta(ChatTimelineState s, ChatEvent e, ChatEntr
12771295 break ;
12781296 }
12791297
1280- // If this assistant response was aborted, show a placeholder
1281- // instead of the actual (partial) content.
1282- if ( shouldMarkAborted )
1283- {
1284- Logger . Debug ( $ "[ChatHistory] → routed: ABORTED (response was stopped)") ;
1285- rebuilt = ApplyAndCaptureMeta (
1286- rebuilt ,
1287- new ChatStatusEvent ( "Response was stopped" , ChatTone . Warning ) ,
1288- msgMeta ) ;
1289- rebuilt = ChatTimelineReducer . Apply ( rebuilt , new ChatTurnEndEvent ( ) ) ;
1290- break ;
1291- }
12921298 // ── Heuristic recovery for history-flattened tool calls ──
12931299 // The gateway strips ``stream:"item"`` / ``command_output``
12941300 // detail server-side when serving ``chat.history`` —
0 commit comments