@@ -48,12 +48,12 @@ import {
48
48
ToolCallArgsEvent ,
49
49
ToolCallEndEvent ,
50
50
ToolCallStartEvent ,
51
+ ToolCallResultEvent ,
51
52
ThinkingTextMessageStartEvent ,
52
53
ThinkingTextMessageContentEvent ,
53
54
ThinkingTextMessageEndEvent ,
54
55
ThinkingStartEvent ,
55
56
ThinkingEndEvent ,
56
- Message as AGUIMessage ,
57
57
} from "@ag-ui/client" ;
58
58
import { RunsStreamPayload } from "@langchain/langgraph-sdk/dist/types" ;
59
59
import {
@@ -76,6 +76,7 @@ export type ProcessedEvents =
76
76
| ToolCallStartEvent
77
77
| ToolCallArgsEvent
78
78
| ToolCallEndEvent
79
+ | ToolCallResultEvent
79
80
| ThinkingStartEvent
80
81
| ThinkingEndEvent
81
82
| StateSnapshotEvent
@@ -774,26 +775,35 @@ export class LangGraphAgent extends AbstractAgent {
774
775
} ) ;
775
776
break ;
776
777
case LangGraphEventTypes . OnToolEnd :
777
- if ( this . activeRun ! . hasFunctionStreaming ) break ;
778
- const toolCallOutput = event . data . output
778
+ const toolCallOutput = event . data ?. output
779
+ if ( ! this . activeRun ! . hasFunctionStreaming ) {
780
+ this . dispatchEvent ( {
781
+ type : EventType . TOOL_CALL_START ,
782
+ toolCallId : toolCallOutput . tool_call_id ,
783
+ toolCallName : toolCallOutput . name ,
784
+ parentMessageId : toolCallOutput . id ,
785
+ rawEvent : event ,
786
+ } )
787
+ this . dispatchEvent ( {
788
+ type : EventType . TOOL_CALL_ARGS ,
789
+ toolCallId : toolCallOutput . tool_call_id ,
790
+ delta : JSON . stringify ( event . data . input ) ,
791
+ rawEvent : event ,
792
+ } ) ;
793
+ this . dispatchEvent ( {
794
+ type : EventType . TOOL_CALL_END ,
795
+ toolCallId : toolCallOutput . tool_call_id ,
796
+ rawEvent : event ,
797
+ } ) ;
798
+ }
779
799
this . dispatchEvent ( {
780
- type : EventType . TOOL_CALL_START ,
800
+ type : EventType . TOOL_CALL_RESULT ,
781
801
toolCallId : toolCallOutput . tool_call_id ,
782
- toolCallName : toolCallOutput . name ,
783
- parentMessageId : toolCallOutput . id ,
784
- rawEvent : event ,
802
+ content : toolCallOutput ?. content ,
803
+ messageId : randomUUID ( ) ,
804
+ role : "tool" ,
785
805
} )
786
- this . dispatchEvent ( {
787
- type : EventType . TOOL_CALL_ARGS ,
788
- toolCallId : toolCallOutput . tool_call_id ,
789
- delta : JSON . stringify ( event . data . input ) ,
790
- rawEvent : event ,
791
- } ) ;
792
- this . dispatchEvent ( {
793
- type : EventType . TOOL_CALL_END ,
794
- toolCallId : toolCallOutput . tool_call_id ,
795
- rawEvent : event ,
796
- } ) ;
806
+ break ;
797
807
}
798
808
}
799
809
0 commit comments