@@ -23,6 +23,7 @@ import {
2323} from "../src/lib/app-owned-memory" ;
2424import {
2525 CURSOR_EXTERNAL_ROOT_BYTE_LIMIT ,
26+ CURSOR_EXTERNAL_TOOL_CONTINUATION_TEXT ,
2627 CURSOR_EXTERNAL_ROOT_BLOB_LIMIT ,
2728 CURSOR_ROUTING_LEVEL_PARAMETER_ID ,
2829 encodeCursorRunRequest ,
@@ -246,7 +247,7 @@ describe("Cursor blob handshake", () => {
246247 const rootBytes = ( run ?. conversationState ?. rootPromptMessagesJson ?? [ ] )
247248 . reduce ( ( sum , id ) => sum + blobData ( id ) . byteLength , 0 ) ;
248249
249- expect ( run ?. action ?. action . case ) . toBe ( "resumeAction " ) ;
250+ expect ( run ?. action ?. action . case ) . toBe ( "userMessageAction " ) ;
250251 expect ( rootBytes ) . toBeLessThanOrEqual ( CURSOR_EXTERNAL_ROOT_BYTE_LIMIT ) ;
251252 expect ( JSON . stringify ( roots ) ) . toContain ( "[Tool Result]" ) ;
252253 expect ( JSON . stringify ( roots ) ) . toContain ( "truncated for Cursor external replay budget" ) ;
@@ -594,7 +595,7 @@ describe("Cursor blob handshake", () => {
594595 expect ( historicalUser ?. content ) . toEqual ( [ { type : "text" , text : "read a file" } ] ) ;
595596 const toolResultRoot = roots . find ( root => JSON . stringify ( root ) . includes ( "[Tool Result]" ) ) ;
596597 expect ( toolResultRoot ?. role ) . toBe ( "assistant" ) ;
597- expect ( run ?. action ?. action . case ) . toBe ( "resumeAction " ) ;
598+ expect ( run ?. action ?. action . case ) . toBe ( "userMessageAction " ) ;
598599 expect ( JSON . stringify ( roots ) ) . toContain ( "contents" ) ;
599600 expect ( JSON . stringify ( roots ) ) . not . toContain ( "hidden reasoning" ) ;
600601 } ) ;
@@ -621,6 +622,36 @@ describe("Cursor blob handshake", () => {
621622
622623 expect ( run ?. action ?. action . case ) . toBe ( "resumeAction" ) ;
623624 } ) ;
625+
626+ test ( "drives external-model tool-result continuations as userMessageAction" , ( ) => {
627+ // External wire models encode tool-result hops as userMessageAction; native
628+ // models keep resumeAction. Tool results stay in the history blobs.
629+ const bytes = encodeCursorRunRequest ( {
630+ modelId : "claude-fable-5" ,
631+ conversationId : "c-ext-cont" ,
632+ system : [ "You are helpful." ] ,
633+ messages : [ { role : "tool" , content : "[tool_result]\ncall_id: call_1\nname: read_file\nis_error: false\noutput:\ncontents" } ] ,
634+ rawMessages : [
635+ { role : "user" , content : "read a file" , timestamp : 1 } ,
636+ {
637+ role : "assistant" ,
638+ model : "cursor/claude-fable-5" ,
639+ timestamp : 2 ,
640+ content : [ { type : "toolCall" , id : "call_1" , name : "read_file" , arguments : { path : "a.txt" } } ] ,
641+ } ,
642+ { role : "toolResult" , toolCallId : "call_1" , toolName : "read_file" , content : "contents" , isError : false , timestamp : 3 } ,
643+ ] ,
644+ } ) ;
645+ const msg = fromBinary ( AgentClientMessageSchema , bytes ) ;
646+ const run = msg . message . case === "runRequest" ? msg . message . value : undefined ;
647+
648+ expect ( run ?. action ?. action . case ) . toBe ( "userMessageAction" ) ;
649+ const value = run ?. action ?. action . case === "userMessageAction" ? run . action . action . value : undefined ;
650+ expect ( value ?. userMessage ?. text ) . toBe ( CURSOR_EXTERNAL_TOOL_CONTINUATION_TEXT ) ;
651+ // Tool results are still replayed via history blobs.
652+ const roots = decodeRootMessages ( bytes ) as Array < { role ?: string } > ;
653+ expect ( JSON . stringify ( roots ) ) . toContain ( "contents" ) ;
654+ } ) ;
624655} ) ;
625656
626657describe ( "Cursor AgentRunRequest.mcp_tools channel" , ( ) => {
0 commit comments