@@ -311,6 +311,56 @@ describe("ChatGPT Responses tool translation", () => {
311311 assert . equal ( next . input [ 1 ] . encrypted_content , "encrypted-json-reasoning" ) ;
312312 } ) ;
313313
314+ it ( "keeps structured reasoning out of visible JSON and streaming content" , async ( ) => {
315+ const json = chatgpt . fromResponsesJson (
316+ {
317+ output : [
318+ {
319+ id : "rs_hidden" ,
320+ type : "reasoning" ,
321+ summary : [ { type : "summary_text" , text : "Private planning" } ] ,
322+ } ,
323+ {
324+ type : "message" ,
325+ role : "assistant" ,
326+ content : [ { type : "output_text" , text : "Visible answer" } ] ,
327+ } ,
328+ ] ,
329+ } ,
330+ "gpt-5.6-sol"
331+ ) ;
332+ assert . equal ( json . choices [ 0 ] . message . content , "Visible answer" ) ;
333+
334+ const events = [
335+ {
336+ type : "response.reasoning_summary_text.delta" ,
337+ delta : "Private streamed planning" ,
338+ } ,
339+ { type : "response.output_text.delta" , delta : "Visible streamed answer" } ,
340+ { type : "response.completed" } ,
341+ ] . map ( ( event ) => `data: ${ JSON . stringify ( event ) } \n\n` ) ;
342+
343+ const collected = await chatgpt . pipeResponsesSse (
344+ Readable . from ( events ) ,
345+ null ,
346+ "gpt-5.6-sol" ,
347+ { collect : true }
348+ ) ;
349+ assert . equal ( collected . choices [ 0 ] . message . content , "Visible streamed answer" ) ;
350+
351+ const writes = [ ] ;
352+ await chatgpt . pipeResponsesSse (
353+ Readable . from ( events ) ,
354+ { write ( chunk ) { writes . push ( chunk ) ; } } ,
355+ "gpt-5.6-sol"
356+ ) ;
357+ const visibleContent = parseSseWrites ( writes )
358+ . map ( ( chunk ) => chunk . choices [ 0 ] . delta . content || "" )
359+ . join ( "" ) ;
360+ assert . equal ( visibleContent , "Visible streamed answer" ) ;
361+ assert . doesNotMatch ( writes . join ( "" ) , / P r i v a t e s t r e a m e d p l a n n i n g / ) ;
362+ } ) ;
363+
314364 it ( "replays multiple reasoning phases once in their original call order" , ( ) => {
315365 const first = chatgpt . fromResponsesJson (
316366 {
0 commit comments