@@ -685,22 +685,25 @@ describe("stripToolCallXmlTags", () => {
685685 expect ( stripToolCallXmlTags ( input , { stripFunctionCallsXmlPayloads : true } ) ) . toBe ( "" ) ;
686686 } ) ;
687687
688- it ( "preserves literal function_response prose after a stripped tool-call block" , ( ) => {
688+ it ( "strips function_response-looking prose adjacent to a stripped tool-call block" , ( ) => {
689689 const input =
690690 '<tool_call>{"name":"exec"}</tool_call>\n\n<function_response> is the response wrapper.' ;
691691
692- expect ( stripToolCallXmlTags ( input , { stripFunctionCallsXmlPayloads : true } ) ) . toBe (
693- "\n\n<function_response> is the response wrapper." ,
694- ) ;
692+ expect ( stripToolCallXmlTags ( input , { stripFunctionCallsXmlPayloads : true } ) ) . toBe ( "\n\n" ) ;
695693 } ) ;
696694
697- it ( "preserves literal closed function_response prose after a stripped tool-call block" , ( ) => {
695+ it ( "strips closed function_response-looking prose adjacent to a stripped tool-call block" , ( ) => {
698696 const input =
699697 '<tool_call>{"name":"exec"}</tool_call>\n<function_response> is the response wrapper; close it with </function_response>.' ;
700698
701- expect ( stripToolCallXmlTags ( input , { stripFunctionCallsXmlPayloads : true } ) ) . toBe (
702- "\n<function_response> is the response wrapper; close it with </function_response>." ,
703- ) ;
699+ expect ( stripToolCallXmlTags ( input , { stripFunctionCallsXmlPayloads : true } ) ) . toBe ( "\n." ) ;
700+ } ) ;
701+
702+ it ( "strips adjacent function_response payloads that match explanation wording" , ( ) => {
703+ const input =
704+ '<function_calls><invoke name="exec">internal</invoke></function_calls><function_response> response wrapper secret</function_response>\nAfter' ;
705+
706+ expect ( stripToolCallXmlTags ( input , { stripFunctionCallsXmlPayloads : true } ) ) . toBe ( "\nAfter" ) ;
704707 } ) ;
705708
706709 it ( "strips compact function_response wrappers while preserving same-line prose tails" , ( ) => {
0 commit comments