@@ -1001,7 +1001,7 @@ export const streamAgent = (
1001
1001
eventSource . onmessage = ( event ) => {
1002
1002
try {
1003
1003
const rawData = event . data ;
1004
- if ( rawData . includes ( '"type":"ping"' ) ) return ;
1004
+ if ( rawData . includes ( '"type": "ping"' ) ) return ;
1005
1005
1006
1006
// Log raw data for debugging (truncated for readability)
1007
1007
console . log (
@@ -1055,18 +1055,15 @@ export const streamAgent = (
1055
1055
1056
1056
// Check for completion messages
1057
1057
if (
1058
- rawData . includes ( '"type":"status"' ) &&
1059
- rawData . includes ( '"status":"completed"' )
1058
+ rawData . includes ( '"type": "status"' ) &&
1059
+ rawData . includes ( '"status": "completed"' )
1060
1060
) {
1061
1061
console . log (
1062
1062
`[STREAM] Detected completion status message for ${ agentRunId } ` ,
1063
1063
) ;
1064
1064
1065
1065
// Check for specific completion messages that indicate we should stop checking
1066
- if (
1067
- rawData . includes ( 'Run data not available for streaming' ) ||
1068
- rawData . includes ( 'Stream ended with status: completed' )
1069
- ) {
1066
+ if ( rawData . includes ( 'Agent run completed successfully' ) ) {
1070
1067
console . log (
1071
1068
`[STREAM] Detected final completion message for ${ agentRunId } , adding to non-running set` ,
1072
1069
) ;
@@ -1087,24 +1084,15 @@ export const streamAgent = (
1087
1084
1088
1085
// Check for thread run end message
1089
1086
if (
1090
- rawData . includes ( '"type":"status"' ) &&
1091
- rawData . includes ( '"status_type":" thread_run_end" ' )
1087
+ rawData . includes ( '"type": "status"' ) &&
1088
+ rawData . includes ( 'thread_run_end' )
1092
1089
) {
1093
1090
console . log (
1094
1091
`[STREAM] Detected thread run end message for ${ agentRunId } ` ,
1095
1092
) ;
1096
1093
1097
- // Add to non-running set
1098
- nonRunningAgentRuns . add ( agentRunId ) ;
1099
-
1100
1094
// Notify about the message
1101
1095
callbacks . onMessage ( rawData ) ;
1102
-
1103
- // Clean up
1104
- eventSource . close ( ) ;
1105
- activeStreams . delete ( agentRunId ) ;
1106
- callbacks . onClose ( ) ;
1107
-
1108
1096
return ;
1109
1097
}
1110
1098
0 commit comments