@@ -2613,6 +2613,82 @@ describe("runCodexAppServerAttempt", () => {
26132613 } ) ;
26142614 } ) ;
26152615
2616+ it ( "does not release or return commentary raw assistant response items" , async ( ) => {
2617+ let notify : ( notification : CodexServerNotification ) => Promise < void > = async ( ) => undefined ;
2618+ const request = vi . fn ( async ( method : string ) => {
2619+ if ( method === "thread/start" ) {
2620+ return threadStartResult ( "thread-1" ) ;
2621+ }
2622+ if ( method === "turn/start" ) {
2623+ return turnStartResult ( "turn-1" , "inProgress" ) ;
2624+ }
2625+ return { } ;
2626+ } ) ;
2627+ setCodexAppServerClientFactoryForTest (
2628+ async ( ) =>
2629+ ( {
2630+ request,
2631+ addNotificationHandler : ( handler : typeof notify ) => {
2632+ notify = handler ;
2633+ return ( ) => undefined ;
2634+ } ,
2635+ addRequestHandler : ( ) => ( ) => undefined ,
2636+ } ) as never ,
2637+ ) ;
2638+ const params = createParams (
2639+ path . join ( tempDir , "session.jsonl" ) ,
2640+ path . join ( tempDir , "workspace" ) ,
2641+ ) ;
2642+ params . timeoutMs = 200 ;
2643+
2644+ const run = runCodexAppServerAttempt ( params , {
2645+ turnAssistantCompletionIdleTimeoutMs : 5 ,
2646+ } ) ;
2647+ await vi . waitFor (
2648+ ( ) =>
2649+ expect ( request ) . toHaveBeenCalledWith ( "turn/start" , expect . anything ( ) , expect . anything ( ) ) ,
2650+ { interval : 1 } ,
2651+ ) ;
2652+ await notify ( {
2653+ method : "rawResponseItem/completed" ,
2654+ params : {
2655+ threadId : "thread-1" ,
2656+ turnId : "turn-1" ,
2657+ item : {
2658+ type : "message" ,
2659+ id : "raw-commentary-1" ,
2660+ role : "assistant" ,
2661+ phase : "commentary" ,
2662+ content : [ { type : "output_text" , text : "I am checking the workspace." } ] ,
2663+ } ,
2664+ } ,
2665+ } ) ;
2666+ await new Promise ( ( resolve ) => setTimeout ( resolve , 20 ) ) ;
2667+
2668+ expect ( request ) . not . toHaveBeenCalledWith ( "turn/interrupt" , expect . anything ( ) ) ;
2669+ await notify ( {
2670+ method : "turn/completed" ,
2671+ params : {
2672+ threadId : "thread-1" ,
2673+ turnId : "turn-1" ,
2674+ turn : { id : "turn-1" , status : "completed" } ,
2675+ } ,
2676+ } ) ;
2677+
2678+ const result = await run ;
2679+ expect ( {
2680+ aborted : result . aborted ,
2681+ timedOut : result . timedOut ,
2682+ promptError : result . promptError ,
2683+ assistantTexts : result . assistantTexts ,
2684+ } ) . toEqual ( {
2685+ aborted : false ,
2686+ timedOut : false ,
2687+ promptError : null ,
2688+ assistantTexts : [ ] ,
2689+ } ) ;
2690+ } ) ;
2691+
26162692 it ( "releases the session after a raw assistant response item without turn completion" , async ( ) => {
26172693 let notify : ( notification : CodexServerNotification ) => Promise < void > = async ( ) => undefined ;
26182694 const request = vi . fn ( async ( method : string ) => {
0 commit comments