@@ -656,7 +656,6 @@ module('Responding', (hooks) => {
656
656
) ;
657
657
} ) ;
658
658
659
- < < < << << HEAD
660
659
test ( 'Handles sequence of thinking -> reasoning -> content correctly' , async ( ) => {
661
660
await responder . ensureThinkingMessageSent ( ) ;
662
661
@@ -762,4 +761,57 @@ module('Responding', (hooks) => {
762
761
) ;
763
762
}
764
763
} ) ;
764
+
765
+ test ( 'Updates message type to command when tool call is in progress' , async ( ) => {
766
+ await responder . initialize ( ) ;
767
+ await responder . onChunk ( {
768
+ id : '0' ,
769
+ created : 0 ,
770
+ model : 'gpt-3.5-turbo' ,
771
+ object : 'chat.completion.chunk' ,
772
+ choices : [
773
+ {
774
+ delta : {
775
+ tool_calls : [
776
+ {
777
+ index : 0 ,
778
+ type : 'function' ,
779
+ function : {
780
+ name : 'patchCard' ,
781
+ arguments : '' ,
782
+ } ,
783
+ } ,
784
+ ] ,
785
+ } ,
786
+ index : 0 ,
787
+ finish_reason : 'stop' ,
788
+ } ,
789
+ ] ,
790
+ } ) ;
791
+
792
+ let sentEvents = fakeMatrixClient . getSentEvents ( ) ;
793
+ assert . equal (
794
+ sentEvents . length ,
795
+ 2 ,
796
+ 'Thinking message and event updating message type should be sent' ,
797
+ ) ;
798
+ assert . equal (
799
+ sentEvents [ 0 ] . content . body ,
800
+ thinkingMessage ,
801
+ 'Thinking message should be sent first' ,
802
+ ) ;
803
+ assert . deepEqual (
804
+ sentEvents [ 1 ] . content [ 'msgtype' ] ,
805
+ APP_BOXEL_COMMAND_MSGTYPE ,
806
+ 'The message type should reflect that the model is preparing a tool call' ,
807
+ ) ;
808
+ assert . deepEqual (
809
+ sentEvents [ 1 ] . content [ 'm.relates_to' ] ,
810
+ {
811
+ rel_type : 'm.replace' ,
812
+ event_id : '0' ,
813
+ } ,
814
+ 'The tool call event should replace the thinking message' ,
815
+ ) ;
816
+ } ) ;
765
817
} ) ;
0 commit comments