File tree Expand file tree Collapse file tree
packages/provider-cursor/src/server Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -308,6 +308,26 @@ describe("CursorAdapterV2", () => {
308308 } ) ,
309309 failure : null ,
310310 } ,
311+ {
312+ reason : "the error a continuation after the turn ended stopped with" ,
313+ updates : [
314+ { type : "text-delta" , text : "The answer." } ,
315+ { type : "turn-ended" } ,
316+ { type : "text-delta" , text : "Following up on the stop hook." } ,
317+ ] 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+ model : { id : "claude-fable-5" } ,
324+ durationMs : 1 ,
325+ } ) ,
326+ failure : {
327+ class : "provider_error" ,
328+ message : "Agent turn stopped after repeated resume attempts made no progress" ,
329+ } ,
330+ } ,
311331 {
312332 reason : "no answer from a resume after the turn ended that made no progress" ,
313333 updates : [ { type : "turn-ended" } ] satisfies ReadonlyArray < InteractionUpdate > ,
Original file line number Diff line number Diff line change @@ -876,6 +876,7 @@ interface ActiveCursorTurn {
876876 readonly reasoning : ActiveCursorTextStream ;
877877 interrupted : boolean ;
878878 finalized : boolean ;
879+ /** The agent's latest turn ended and no new work has started since. */
879880 turnEnded : boolean ;
880881}
881882
@@ -1920,6 +1921,15 @@ export const makeCursorAdapterV2 = Effect.fn("makeCursorAdapterV2")(function* (
19201921 if ( context . finalized ) {
19211922 return ;
19221923 }
1924+ if ( update . type === "turn-ended" ) {
1925+ context . turnEnded = true ;
1926+ } else if (
1927+ update . type === "text-delta" ||
1928+ update . type === "thinking-delta" ||
1929+ update . type === "tool-call-started"
1930+ ) {
1931+ context . turnEnded = false ;
1932+ }
19231933 switch ( update . type ) {
19241934 case "text-delta" :
19251935 // Classify each assistant message on its own, so earlier
@@ -1959,7 +1969,6 @@ export const makeCursorAdapterV2 = Effect.fn("makeCursorAdapterV2")(function* (
19591969 return ;
19601970 case "step-completed" :
19611971 case "turn-ended" :
1962- context . turnEnded ||= update . type === "turn-ended" ;
19631972 yield * completeAssistant ( context ) ;
19641973 yield * completeReasoning ( context ) ;
19651974 return ;
You can’t perform that action at this time.
0 commit comments