@@ -2104,6 +2104,33 @@ describe("createCliJsonlStreamingParser", () => {
21042104 expect ( parser . getOutput ( ) ?. text ) . toBe ( "Visible answer." ) ;
21052105 } ) ;
21062106
2107+ it ( "streams rejected angle prefixes while valid split reasoning stays buffered" , ( ) => {
2108+ const visible = createClaudeTaggedReasoningHarness ( ) ;
2109+ const tagged = createClaudeTaggedReasoningHarness ( ) ;
2110+ const pushText = ( parser : ReturnType < typeof createCliJsonlStreamingParser > , text : string ) =>
2111+ parser . push (
2112+ `${ JSON . stringify ( {
2113+ type : "stream_event" ,
2114+ event : {
2115+ type : "content_block_delta" ,
2116+ delta : { type : "text_delta" , text } ,
2117+ } ,
2118+ } ) } \n`,
2119+ ) ;
2120+
2121+ pushText ( visible . parser , "<div>Visible answer.</div>" ) ;
2122+ expect ( visible . assistant . at ( - 1 ) ?. text ) . toBe ( "<div>Visible answer.</div>" ) ;
2123+ expect ( visible . parser . getOutput ( ) ?. text ) . toBe ( "<div>Visible answer.</div>" ) ;
2124+
2125+ pushText ( tagged . parser , "<thi" ) ;
2126+ pushText ( tagged . parser , "nking>Private analysis." ) ;
2127+ expect ( tagged . assistant ) . toEqual ( [ ] ) ;
2128+ expect ( tagged . thinking ) . toEqual ( [ ] ) ;
2129+ pushText ( tagged . parser , "</thinking>Visible answer." ) ;
2130+ expect ( tagged . thinking . at ( - 1 ) ?. text ) . toBe ( "Private analysis." ) ;
2131+ expect ( tagged . assistant . at ( - 1 ) ?. text ) . toBe ( "Visible answer." ) ;
2132+ } ) ;
2133+
21072134 it ( "promotes consecutive leading blocks but preserves later literal tags" , ( ) => {
21082135 const { assistant, parser, thinking } = createClaudeTaggedReasoningHarness ( ) ;
21092136
0 commit comments