@@ -480,76 +480,6 @@ describe("addToolCallDeltaToState", () => {
480480 expect ( currentState . parsedArgs ) . toEqual ( { location : "Paris, France" } ) ;
481481 } ) ;
482482
483- it ( "should handle arguments streamed in full progressive chunks" , ( ) => {
484- // Test case where model streams args progressively but includes full prefix each time
485- // e.g. '{"query":"te' -> '{"query":"tes' -> '{"query":"test"}'
486- const currentState : ToolCallState = {
487- status : "generating" ,
488- toolCall : {
489- id : "call123" ,
490- type : "function" ,
491- function : {
492- name : "searchFiles" ,
493- arguments : '{"query":"te' ,
494- } ,
495- } ,
496- toolCallId : "call123" ,
497- parsedArgs : { query : "te" } ,
498- } ;
499-
500- const delta : ToolCallDelta = {
501- function : {
502- arguments : '{"query":"tes' ,
503- } ,
504- } ;
505-
506- const result = addToolCallDeltaToState ( delta , currentState ) ;
507- expect ( result . toolCall . function . arguments ) . toBe ( '{"query":"tes' ) ;
508- expect ( result . parsedArgs ) . toEqual ( { query : "tes" } ) ;
509-
510- // Continue the streaming
511- const nextDelta : ToolCallDelta = {
512- function : {
513- arguments : '{"query":"test"}' ,
514- } ,
515- } ;
516-
517- const finalResult = addToolCallDeltaToState ( nextDelta , result ) ;
518- expect ( finalResult . toolCall . function . arguments ) . toBe ( '{"query":"test"}' ) ;
519- expect ( finalResult . parsedArgs ) . toEqual ( { query : "test" } ) ;
520- } ) ;
521-
522- it ( "should handle when args delta is a superset of current args" , ( ) => {
523- // Test case where model sends a subset of the current arguments
524- // This can happen in certain LLM implementations
525- const currentState : ToolCallState = {
526- status : "generating" ,
527- toolCall : {
528- id : "call123" ,
529- type : "function" ,
530- function : {
531- name : "searchFiles" ,
532- arguments : '{"query":"test"' ,
533- } ,
534- } ,
535- toolCallId : "call123" ,
536- parsedArgs : { query : "test" } ,
537- } ;
538-
539- const delta : ToolCallDelta = {
540- function : {
541- arguments : '{"query":"test","limit":10}' ,
542- } ,
543- } ;
544-
545- // The subset should be ignored, keeping the current state
546- const result = addToolCallDeltaToState ( delta , currentState ) ;
547- expect ( result . toolCall . function . arguments ) . toBe (
548- '{"query":"test","limit":10}' ,
549- ) ;
550- expect ( result . parsedArgs ) . toEqual ( { query : "test" , limit : 10 } ) ;
551- } ) ;
552-
553483 it ( "should handle when args are complete JSON and new deltas arrive" , ( ) => {
554484 // When args are already a valid JSON object, new deltas should not modify it
555485 const currentState : ToolCallState = {
0 commit comments