@@ -946,6 +946,8 @@ interface ActiveCursorTurn {
946946 readonly assistant : ActiveCursorTextStream ;
947947 assistantReply : CursorTransportFailure ;
948948 readonly reasoning : ActiveCursorTextStream ;
949+ /** The user text this run sent, before runtime instructions; absent for /compress. */
950+ readonly prompt : string | undefined ;
949951 interrupted : boolean ;
950952 finalized : boolean ;
951953 /** The agent's latest turn ended and no new work has started since. */
@@ -1004,6 +1006,11 @@ export const makeCursorAdapterV2 = Effect.fn("makeCursorAdapterV2")(function* (
10041006 readonly orchestration : boolean ;
10051007 readonly device : boolean ;
10061008 } | null > ( null ) ;
1009+ // Cursor drops a cancelled run from the conversation, so the next message carries its prompt.
1010+ const interruptedPrompt = yield * Ref . make < {
1011+ readonly agent : string ;
1012+ readonly text : string ;
1013+ } | null > ( null ) ;
10071014 const warnedUnsupportedSandbox = yield * Ref . make ( false ) ;
10081015 const activeTurn = yield * Ref . make < ActiveCursorTurn | null > ( null ) ;
10091016 const planIds = yield * Ref . make ( new Map < string , OrchestrationV2PlanArtifact [ "id" ] > ( ) ) ;
@@ -2192,6 +2199,12 @@ export const makeCursorAdapterV2 = Effect.fn("makeCursorAdapterV2")(function* (
21922199 threadDisposition,
21932200 } ,
21942201 ) ;
2202+ if ( input . status === "interrupted" && input . context . prompt !== undefined ) {
2203+ yield * Ref . set ( interruptedPrompt , {
2204+ agent : input . context . run . agentId ,
2205+ text : input . context . prompt ,
2206+ } ) ;
2207+ }
21952208 yield * Ref . update ( activeTurn , ( current ) =>
21962209 current ?. providerTurnId === input . context . providerTurnId ? null : current ,
21972210 ) ;
@@ -2284,10 +2297,11 @@ export const makeCursorAdapterV2 = Effect.fn("makeCursorAdapterV2")(function* (
22842297 mcpServers : Record < string , McpServerConfig > | undefined ,
22852298 hasDeviceTools : boolean ,
22862299 delivered : { readonly orchestration : boolean ; readonly device : boolean } ,
2300+ interrupted : string | undefined ,
22872301 ) {
22882302 const rawText = turnInput . message . text ;
22892303 if ( rawText . trim ( ) === "/compress" && turnInput . message . attachments . length === 0 ) {
2290- return "/compress" ;
2304+ return { message : "/compress" , prompt : undefined } ;
22912305 }
22922306 if ( hasCursorSkillMention ( rawText ) && cursorSkillNames === undefined ) {
22932307 const skills = yield * discoverCursorSkills (
@@ -2303,7 +2317,7 @@ export const makeCursorAdapterV2 = Effect.fn("makeCursorAdapterV2")(function* (
23032317 . map ( ( skill ) => skill . name ) ,
23042318 ) ;
23052319 }
2306- const userText = t3OrchestrationPrompt ( {
2320+ const newText = t3OrchestrationPrompt ( {
23072321 prompt : yield * providerMessageTextWithAttachmentPaths ( {
23082322 text :
23092323 cursorSkillNames === undefined
@@ -2318,6 +2332,10 @@ export const makeCursorAdapterV2 = Effect.fn("makeCursorAdapterV2")(function* (
23182332 orchestrationDelivered : delivered . orchestration ,
23192333 deviceInstructionsDelivered : delivered . device ,
23202334 } ) ;
2335+ const userText =
2336+ interrupted === undefined
2337+ ? newText
2338+ : `Your previous turn was interrupted and is missing from your history. Some of its work may already be done. Its request was:\n\n${ interrupted } \n\nThe new message, which may continue or change that request:\n\n${ newText } ` ;
23212339 const images = yield * Effect . forEach (
23222340 turnInput . message . attachments . filter ( isProviderNativeImageAttachment ) ,
23232341 ( attachment : ChatAttachment ) =>
@@ -2354,12 +2372,10 @@ export const makeCursorAdapterV2 = Effect.fn("makeCursorAdapterV2")(function* (
23542372 } ) ;
23552373 }
23562374 const text = `${ userText } \n\n${ buildRuntimeInstructions ( { harness : "Cursor" , model : turnInput . modelSelection . model } ) } ` ;
2357- return images . length === 0
2358- ? text
2359- : ( {
2360- text,
2361- images,
2362- } satisfies SDKUserMessage ) ;
2375+ return {
2376+ message : images . length === 0 ? text : ( { text, images } satisfies SDKUserMessage ) ,
2377+ prompt : userText ,
2378+ } ;
23632379 } ) ;
23642380
23652381 const startTurn = Effect . fn ( "CursorAdapterV2.startTurn" ) (
@@ -2390,13 +2406,15 @@ export const makeCursorAdapterV2 = Effect.fn("makeCursorAdapterV2")(function* (
23902406 known ?. agent === agent . nativeThreadId
23912407 ? known
23922408 : { orchestration : turnInput . runOrdinal > 1 , device : false } ;
2393- const message = yield * resolveUserMessage (
2409+ const interrupted = yield * Ref . get ( interruptedPrompt ) ;
2410+ const { message, prompt } = yield * resolveUserMessage (
23942411 turnInput ,
23952412 mcpServers ,
23962413 hasDeviceTools ,
23972414 delivered ,
2415+ interrupted ?. agent === agent . nativeThreadId ? interrupted . text : undefined ,
23982416 ) ;
2399- const compacted = message === "/compress" ;
2417+ const compacted = prompt === undefined ;
24002418 const pendingUpdates : Array < InteractionUpdate > = [ ] ;
24012419 let context : ActiveCursorTurn | null = null ;
24022420 // Create-time and send-time mcpServers merge with settingSources (SDK >= 1.0.39).
@@ -2424,6 +2442,9 @@ export const makeCursorAdapterV2 = Effect.fn("makeCursorAdapterV2")(function* (
24242442 orchestration : ! compacted && ( delivered . orchestration || mcpServers !== undefined ) ,
24252443 device : ! compacted && hasDeviceTools ,
24262444 } ) ;
2445+ if ( ! compacted ) {
2446+ yield * Ref . set ( interruptedPrompt , null ) ;
2447+ }
24272448 const startedAt = yield * DateTime . now ;
24282449 const completed = yield * Deferred . make < void , never > ( ) ;
24292450 const providerTurnId = idAllocator . derive . providerTurn ( {
@@ -2448,6 +2469,7 @@ export const makeCursorAdapterV2 = Effect.fn("makeCursorAdapterV2")(function* (
24482469 current : null ,
24492470 nextSegment : 0 ,
24502471 } ,
2472+ prompt,
24512473 interrupted : false ,
24522474 finalized : false ,
24532475 turnEnded : false ,
0 commit comments