@@ -272,7 +272,62 @@ describe("CursorAdapterV2", () => {
272272 } ) ,
273273 failure : { class : "transport_error" , message : "Provider turn failed." } ,
274274 } ,
275- ] ) ( "fails the turn with $reason" , ( { updates = [ ] , wait, failure } ) =>
275+ {
276+ reason : "no failure when Cursor's resume after the turn ended made no progress" ,
277+ // Cursor's SDK resumed from an older checkpoint after the answer was
278+ // delivered, regenerated the closing, then gave up on the run.
279+ updates : [
280+ { type : "text-delta" , text : "The answer." } ,
281+ { type : "turn-ended" } ,
282+ { type : "text-delta" , text : "A regenerated closing." } ,
283+ { type : "turn-ended" } ,
284+ ] satisfies ReadonlyArray < InteractionUpdate > ,
285+ wait : Effect . succeed ( {
286+ id : "native-cursor-run" ,
287+ requestId : "native-request" ,
288+ status : "error" as const ,
289+ error : { message : "Agent turn stopped after repeated resume attempts made no progress" } ,
290+ model : { id : "claude-fable-5" } ,
291+ durationMs : 1 ,
292+ } ) ,
293+ failure : null ,
294+ } ,
295+ {
296+ reason : "the error a continuation after the turn ended stopped with" ,
297+ updates : [
298+ { type : "text-delta" , text : "The answer." } ,
299+ { type : "turn-ended" } ,
300+ { type : "text-delta" , text : "Following up on the stop hook." } ,
301+ ] satisfies ReadonlyArray < InteractionUpdate > ,
302+ wait : Effect . succeed ( {
303+ id : "native-cursor-run" ,
304+ requestId : "native-request" ,
305+ status : "error" as const ,
306+ error : { message : "Agent turn stopped after repeated resume attempts made no progress" } ,
307+ model : { id : "claude-fable-5" } ,
308+ durationMs : 1 ,
309+ } ) ,
310+ failure : {
311+ class : "provider_error" ,
312+ message : "Agent turn stopped after repeated resume attempts made no progress" ,
313+ } ,
314+ } ,
315+ {
316+ reason : "no answer from a resume after the turn ended that made no progress" ,
317+ updates : [ { type : "turn-ended" } ] satisfies ReadonlyArray < InteractionUpdate > ,
318+ wait : Effect . succeed ( {
319+ id : "native-cursor-run" ,
320+ requestId : "native-request" ,
321+ status : "error" as const ,
322+ error : { message : "Agent turn stopped after repeated resume attempts made no progress" } ,
323+ result : "A regenerated closing." ,
324+ model : { id : "claude-fable-5" } ,
325+ durationMs : 1 ,
326+ } ) ,
327+ failure : null ,
328+ answers : [ ] ,
329+ } ,
330+ ] ) ( "ends the turn with $reason" , ( { updates = [ ] , wait, failure, answers } ) =>
276331 Effect . gen ( function * ( ) {
277332 const fileSystem = yield * FileSystem . FileSystem ;
278333 const workspace = yield * fileSystem . makeTempDirectoryScoped ( { prefix : "cursor-v2-failure-" } ) ;
@@ -365,15 +420,23 @@ describe("CursorAdapterV2", () => {
365420 attachments : [ ] ,
366421 } ,
367422 } ) ;
368- const terminal = yield * runtime . events . pipe (
369- Stream . filter ( ( event ) => event . type === "turn.terminal" ) ,
370- Stream . runHead ,
423+ const events = yield * runtime . events . pipe (
424+ Stream . takeUntil ( ( event ) => event . type === "turn.terminal" ) ,
425+ Stream . runCollect ,
371426 ) ;
372- assert . isTrue ( Option . isSome ( terminal ) ) ;
373- if ( Option . isSome ( terminal ) ) {
374- assert . equal ( terminal . value . status , "failed" ) ;
375- assert . equal ( terminal . value . failure ?. class , failure . class ) ;
376- assert . equal ( terminal . value . failure ?. message , failure . message ) ;
427+ const terminal = events . find ( ( event ) => event . type === "turn.terminal" ) ;
428+ assert . equal ( terminal ?. status , failure === null ? "completed" : "failed" ) ;
429+ assert . equal ( terminal ?. failure ?. class , failure ?. class ) ;
430+ assert . equal ( terminal ?. failure ?. message , failure ?. message ) ;
431+ if ( answers !== undefined ) {
432+ assert . deepEqual (
433+ events . flatMap ( ( event ) =>
434+ event . type === "message.updated" && event . message . role === "assistant"
435+ ? [ event . message . text ]
436+ : [ ] ,
437+ ) ,
438+ answers ,
439+ ) ;
377440 }
378441 } ) . pipe (
379442 Effect . scoped ,
0 commit comments