@@ -248,6 +248,19 @@ const openAiSplitVisibleReasoningDetailsChunks = [
248248 makeOpenAiChunk ( { } , "stop" ) ,
249249] satisfies OpenAIChunk [ ] ;
250250
251+ const openAiVisibleDetailBeforeInterruptedContentChunks = [
252+ makeOpenAiChunk ( {
253+ reasoning_details : [ { type : "response.output_text" , text : "Visible first." } ] ,
254+ } ) ,
255+ makeOpenAiChunk ( {
256+ reasoning_details : [ { type : "reasoning.text" , text : " Hidden second." } ] ,
257+ } ) ,
258+ makeOpenAiChunk ( { content : "Interim." } ) ,
259+ makeOpenAiChunk ( { reasoning_content : "Hidden fourth." } ) ,
260+ makeOpenAiChunk ( { content : "Final." } ) ,
261+ makeOpenAiChunk ( { } , "stop" ) ,
262+ ] satisfies OpenAIChunk [ ] ;
263+
251264const openAiTrailingReasoningChunks = [
252265 makeOpenAiChunk ( { reasoning_content : "First thought." } ) ,
253266 makeOpenAiChunk ( { content : "Answer." } ) ,
@@ -723,4 +736,44 @@ describe("provider and transport observable parity fixtures", () => {
723736 }
724737 }
725738 } ) ;
739+
740+ it ( "preserves earlier visible details when later ordinary content is interrupted" , async ( ) => {
741+ for ( const implementation of [ "provider" , "transport" ] as const ) {
742+ const result = await runOpenAi (
743+ implementation ,
744+ "success" ,
745+ openAiVisibleDetailBeforeInterruptedContentChunks ,
746+ true ,
747+ openRouterModel ,
748+ ) ;
749+
750+ expect ( result . terminal . content ) . toEqual ( [
751+ {
752+ type : "text" ,
753+ text : "Visible first." ,
754+ textSignature : '{"v":1,"id":"final-answer-0","phase":"final_answer"}' ,
755+ } ,
756+ {
757+ type : "thinking" ,
758+ thinking : " Hidden second." ,
759+ thinkingSignature : "reasoning_details" ,
760+ } ,
761+ {
762+ type : "text" ,
763+ text : "Interim." ,
764+ textSignature : '{"v":1,"id":"commentary-0","phase":"commentary"}' ,
765+ } ,
766+ {
767+ type : "thinking" ,
768+ thinking : "Hidden fourth." ,
769+ thinkingSignature : "reasoning_content" ,
770+ } ,
771+ {
772+ type : "text" ,
773+ text : "Final." ,
774+ textSignature : '{"v":1,"id":"final-answer-1","phase":"final_answer"}' ,
775+ } ,
776+ ] ) ;
777+ }
778+ } ) ;
726779} ) ;
0 commit comments