File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -333,15 +333,14 @@ export class OpenClaw {
333333 ) : AsyncIterable < OpenClawEvent > {
334334 await this . connect ( ) ;
335335 const replayEvents = this . replaySnapshot ( runId ) ;
336- let hasAssistantRunEvent = replayEvents . some ( isAssistantRunEvent ) ;
336+ let hasCanonicalAssistantRunEvent = replayEvents . some ( isAssistantRunEvent ) ;
337337 let hasTerminalRunEvent = replayEvents . some ( isTerminalRunEvent ) ;
338338 const toRunStreamEvent = ( event : OpenClawEvent ) : OpenClawEvent | undefined => {
339339 const chatProjection = readChatProjection ( event ) ;
340340 if ( chatProjection ?. state === "delta" ) {
341- if ( hasAssistantRunEvent ) {
341+ if ( hasCanonicalAssistantRunEvent ) {
342342 return undefined ;
343343 }
344- hasAssistantRunEvent = true ;
345344 return normalizeChatProjectionEvent ( event , chatProjection ) ;
346345 }
347346 if ( chatProjection ?. state === "final" ) {
@@ -352,7 +351,7 @@ export class OpenClaw {
352351 return normalizeChatProjectionEvent ( event , chatProjection ) ;
353352 }
354353 if ( isAssistantRunEvent ( event ) ) {
355- hasAssistantRunEvent = true ;
354+ hasCanonicalAssistantRunEvent = true ;
356355 }
357356 if ( isTerminalRunEvent ( event ) ) {
358357 hasTerminalRunEvent = true ;
Original file line number Diff line number Diff line change @@ -485,20 +485,34 @@ describe("OpenClaw SDK", () => {
485485 payload : {
486486 runId : "run_chat_only" ,
487487 sessionKey : "chat-only" ,
488- state : "final " ,
488+ state : "delta " ,
489489 message : {
490490 role : "assistant" ,
491- content : [ { type : "text" , text : "hello" } ] ,
491+ content : [ { type : "text" , text : "hello again " } ] ,
492492 timestamp : ts + 1 ,
493493 } ,
494494 } ,
495495 } ) ;
496496 fake . emit ( {
497- event : "custom.debug " ,
497+ event : "chat " ,
498498 seq : 3 ,
499499 payload : {
500500 runId : "run_chat_only" ,
501- ts : ts + 2 ,
501+ sessionKey : "chat-only" ,
502+ state : "final" ,
503+ message : {
504+ role : "assistant" ,
505+ content : [ { type : "text" , text : "hello again" } ] ,
506+ timestamp : ts + 2 ,
507+ } ,
508+ } ,
509+ } ) ;
510+ fake . emit ( {
511+ event : "custom.debug" ,
512+ seq : 4 ,
513+ payload : {
514+ runId : "run_chat_only" ,
515+ ts : ts + 3 ,
502516 data : { ok : true } ,
503517 } ,
504518 } ) ;
@@ -527,10 +541,20 @@ describe("OpenClaw SDK", () => {
527541
528542 const second = await iterator . next ( ) ;
529543 expect ( second ) . toMatchObject ( {
544+ done : false ,
545+ value : {
546+ type : "assistant.delta" ,
547+ data : { delta : "hello again" } ,
548+ raw : { event : "chat" } ,
549+ } ,
550+ } ) ;
551+
552+ const third = await iterator . next ( ) ;
553+ expect ( third ) . toMatchObject ( {
530554 done : false ,
531555 value : {
532556 type : "run.completed" ,
533- data : { phase : "end" , outputText : "hello" } ,
557+ data : { phase : "end" , outputText : "hello again " } ,
534558 raw : { event : "chat" } ,
535559 } ,
536560 } ) ;
You can’t perform that action at this time.
0 commit comments