@devries-cameron20 / t3code-1 / commits / d313b2aff3
Fork 0

The best way to control Claude Code, Codex and more from any computer or phone

fix(cursor): a steer keeps the prompt it interrupted (#32583)

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>

Julius Marminge committed Nov 10, 2026 at 06:15 UTC d313b2aff31991ab94c8ac80cdc38a54dd575604
3 files changed +179 -11
apps/server/src/orchestration-v2/testkit/fixtures/message_steering/cursor_transcript.ndjson
+1 -1
@@ -6,7 +6,7 @@
6 {"type":"emit_inbound","label":"thinking-delta","frame":{"type":"interaction.update","runId":"run-046488f0-f621-4d59-976c-c4c935ad1282","update":{"type":"thinking-delta","text":"The user requested the"}}}
7 {"type":"expect_outbound","label":"run.cancel:1","frame":{"type":"run.cancel","runId":"run-046488f0-f621-4d59-976c-c4c935ad1282"}}
8 {"type":"emit_inbound","label":"run.completed:1","frame":{"type":"run.completed","result":{"id":"run-046488f0-f621-4d59-976c-c4c935ad1282","requestId":"d3b97820-1cf3-448d-a4b1-5fa7edc21460","status":"cancelled","model":{"id":"composer-2.5"},"durationMs":3177}}}
9 -{"type":"expect_outbound","label":"run.start:2","frame":{"type":"run.start","message":"Actually, respond with exactly: steering fixture observed","options":{"model":{"id":"composer-2.5"},"mode":"agent"}}}
9 +{"type":"expect_outbound","label":"run.start:2","frame":{"type":"run.start","message":"Your previous turn was interrupted and is missing from your history. Some of its work may already be done. Its request was:\n\nRespond with exactly: steering fixture initial response\n\nThe new message, which may continue or change that request:\n\nActually, respond with exactly: steering fixture observed","options":{"model":{"id":"composer-2.5"},"mode":"agent"}}}
10 {"type":"emit_inbound","label":"run.started:2","frame":{"type":"run.started","runId":"run-e3b66d77-b2d4-4791-be2b-1a35c8e997d1","agentId":"agent-575fd75e-3fd7-412e-9b74-36f3a5aa5371"}}
11 {"type":"emit_inbound","label":"thinking-delta","frame":{"type":"interaction.update","runId":"run-e3b66d77-b2d4-4791-be2b-1a35c8e997d1","update":{"type":"thinking-delta","text":"The response will be"}}}
12 {"type":"emit_inbound","label":"token-delta","frame":{"type":"interaction.update","runId":"run-e3b66d77-b2d4-4791-be2b-1a35c8e997d1","update":{"type":"token-delta","tokens":5}}}
packages/provider-cursor/src/server/adapter.test.ts
+146
@@ -14,6 +14,7 @@ import {
14 ThreadId,
15 } from "@t3tools/contracts";
16 import * as DateTime from "effect/DateTime";
17 +import * as Deferred from "effect/Deferred";
18 import * as Effect from "effect/Effect";
19 import * as FileSystem from "effect/FileSystem";
20 import * as Layer from "effect/Layer";
@@ -812,6 +813,151 @@ describe("CursorAdapterV2", () => {
813 ),
814 );
815
816 + it.effect("carries an interrupted prompt into the steer that restarts the turn", () =>
817 + Effect.gen(function* () {
818 + const fileSystem = yield* FileSystem.FileSystem;
819 + const workspace = yield* fileSystem.makeTempDirectoryScoped({ prefix: "cursor-v2-steer-" });
820 + const sentMessages: Array<string> = [];
821 + const runEnds: Array<Deferred.Deferred<"finished" | "cancelled">> = [];
822 + const instanceId = ProviderInstanceId.make("cursor");
823 + const threadId = ThreadId.make("cursor-steer-thread");
824 + const modelSelection = { instanceId, model: "composer-2.5" };
825 + const runtimePolicy = ProviderAdapter.ProviderAdapterV2RuntimePolicy.make({
826 + runtimeMode: "full-access",
827 + interactionMode: "default",
828 + cwd: workspace,
829 + });
830 + const adapter = yield* makeCursorAdapterV2({
831 + instanceId,
832 + environment: { HOME: workspace },
833 + }).pipe(
834 + Effect.provideService(CursorAgentSdk.CursorAgentSdkRunner, {
835 + assertComplete: Effect.void,
836 + open: () =>
837 + Effect.succeed({
838 + agentId: "native-cursor-steer",
839 + listMessages: Effect.succeed([]),
840 + close: Effect.void,
841 + send: (input) =>
842 + Effect.gen(function* () {
843 + sentMessages.push(
844 + typeof input.message === "string" ? input.message : input.message.text,
845 + );
846 + const runId = `native-cursor-run-${sentMessages.length}`;
847 + const ended = yield* Deferred.make<"finished" | "cancelled">();
848 + runEnds.push(ended);
849 + return {
850 + agentId: "native-cursor-steer",
851 + runId,
852 + // Cursor drops a cancelled run's prompt from the agent's conversation.
853 + wait: Deferred.await(ended).pipe(
854 + Effect.map((status) => ({
855 + id: runId,
856 + requestId: `native-request-${sentMessages.length}`,
857 + status,
858 + model: { id: "composer-2.5" },
859 + durationMs: 1,
860 + })),
861 + ),
862 + cancel: Deferred.succeed(ended, "cancelled"),
863 + };
864 + }),
865 + }),
866 + }),
867 + Effect.provide(TestProviderHost.layer({ cwd: workspace })),
868 + );
869 + const runtime = yield* adapter.openSession({
870 + threadId,
871 + providerSessionId: ProviderSessionId.make("cursor-steer-session"),
872 + modelSelection,
873 + runtimePolicy,
874 + });
875 + const providerThread = yield* runtime.ensureThread({
876 + threadId,
877 + modelSelection,
878 + runtimePolicy,
879 + });
880 + const now = yield* DateTime.now;
881 + const appThread = {
882 + id: threadId,
883 + projectId: ProjectId.make("cursor-steer-project"),
884 + createdBy: "user" as const,
885 + creationSource: "web" as const,
886 + title: "Cursor steer",
887 + providerInstanceId: instanceId,
888 + modelSelection,
889 + runtimeMode: "full-access" as const,
890 + interactionMode: "default" as const,
891 + branch: null,
892 + worktreePath: null,
893 + activeProviderThreadId: providerThread.id,
894 + lineage: { parentThreadId: null, relationshipToParent: null, rootThreadId: threadId },
895 + forkedFrom: null,
896 + createdAt: now,
897 + updatedAt: now,
898 + archivedAt: null,
899 + settledOverride: null,
900 + settledAt: null,
901 + lastVisitedAt: null,
902 + deletedAt: null,
903 + };
904 + const turnInput = (runOrdinal: number, text: string) => ({
905 + threadId,
906 + providerThread,
907 + modelSelection,
908 + runtimePolicy,
909 + runId: RunId.make(`cursor-steer-run-${runOrdinal}`),
910 + runOrdinal,
911 + providerTurnOrdinal: runOrdinal,
912 + attemptId: RunAttemptId.make(`cursor-steer-attempt-${runOrdinal}`),
913 + rootNodeId: NodeId.make(`cursor-steer-root-${runOrdinal}`),
914 + appThread,
915 + message: {
916 + messageId: MessageId.make(`cursor-steer-message-${runOrdinal}`),
917 + createdBy: "user" as const,
918 + creationSource: "web" as const,
919 + text,
920 + attachments: [],
921 + },
922 + });
923 + const firstPrompt = "Write me a 1000 word story about a dog.";
924 + const steerText = "No wait, a pig please.";
925 +
926 + yield* runtime.startTurn(turnInput(1, firstPrompt));
927 + const started = Option.getOrThrow(
928 + yield* runtime.events.pipe(
929 + Stream.filter((event) => event.type === "provider_turn.updated"),
930 + Stream.runHead,
931 + ),
932 + );
933 + assert(started.type === "provider_turn.updated");
934 + yield* runtime.interruptTurn({ providerThread, providerTurnId: started.providerTurn.id });
935 + yield* runtime.startTurn(turnInput(2, steerText));
936 +
937 + assert.lengthOf(sentMessages, 2);
938 + const steered = sentMessages[1]!;
939 + assert.include(steered, steerText);
940 + assert.include(
941 + steered,
942 + firstPrompt,
943 + "the interrupted prompt is missing from the run that replaces it",
944 + );
945 +
946 + yield* Deferred.succeed(runEnds[1]!, "finished");
947 + yield* runtime.events.pipe(
948 + Stream.filter((event) => event.type === "turn.terminal" && event.status === "completed"),
949 + Stream.runHead,
950 + );
951 + yield* runtime.startTurn(turnInput(3, "Now a cow."));
952 + assert.notInclude(sentMessages[2]!, firstPrompt, "a finished turn carries nothing forward");
953 + }).pipe(
954 + Effect.scoped,
955 + Effect.provide(
956 + Layer.mergeAll(NodeServices.layer, IdAllocator.layer, McpProviderSessions.layer),
957 + ),
958 + ),
959 + );
960 +
961 it.effect("projects Cursor directory trees and lint diagnostics as file search results", () =>
962 Effect.gen(function* () {
963 const fileSystem = yield* FileSystem.FileSystem;
packages/provider-cursor/src/server/adapter.ts
+32 -10
@@ -946,6 +946,8 @@ interface ActiveCursorTurn {
946 readonly assistant: ActiveCursorTextStream;
947 assistantReply: CursorTransportFailure;
948 readonly reasoning: ActiveCursorTextStream;
949 + /** The user text this run sent, before runtime instructions; absent for /compress. */
950 + readonly prompt: string | undefined;
951 interrupted: boolean;
952 finalized: boolean;
953 /** The agent's latest turn ended and no new work has started since. */
@@ -1004,6 +1006,11 @@ export const makeCursorAdapterV2 = Effect.fn("makeCursorAdapterV2")(function* (
1006 readonly orchestration: boolean;
1007 readonly device: boolean;
1008 } | 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);
1014 const warnedUnsupportedSandbox = yield* Ref.make(false);
1015 const activeTurn = yield* Ref.make<ActiveCursorTurn | null>(null);
1016 const planIds = yield* Ref.make(new Map<string, OrchestrationV2PlanArtifact["id"]>());
@@ -2192,6 +2199,12 @@ export const makeCursorAdapterV2 = Effect.fn("makeCursorAdapterV2")(function* (
2199 threadDisposition,
2200 },
2201 );
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 + }
2208 yield* Ref.update(activeTurn, (current) =>
2209 current?.providerTurnId === input.context.providerTurnId ? null : current,
2210 );
@@ -2284,10 +2297,11 @@ export const makeCursorAdapterV2 = Effect.fn("makeCursorAdapterV2")(function* (
2297 mcpServers: Record<string, McpServerConfig> | undefined,
2298 hasDeviceTools: boolean,
2299 delivered: { readonly orchestration: boolean; readonly device: boolean },
2300 + interrupted: string | undefined,
2301 ) {
2302 const rawText = turnInput.message.text;
2303 if (rawText.trim() === "/compress" && turnInput.message.attachments.length === 0) {
2290 - return "/compress";
2304 + return { message: "/compress", prompt: undefined };
2305 }
2306 if (hasCursorSkillMention(rawText) && cursorSkillNames === undefined) {
2307 const skills = yield* discoverCursorSkills(
@@ -2303,7 +2317,7 @@ export const makeCursorAdapterV2 = Effect.fn("makeCursorAdapterV2")(function* (
2317 .map((skill) => skill.name),
2318 );
2319 }
2306 - const userText = t3OrchestrationPrompt({
2320 + const newText = t3OrchestrationPrompt({
2321 prompt: yield* providerMessageTextWithAttachmentPaths({
2322 text:
2323 cursorSkillNames === undefined
@@ -2318,6 +2332,10 @@ export const makeCursorAdapterV2 = Effect.fn("makeCursorAdapterV2")(function* (
2332 orchestrationDelivered: delivered.orchestration,
2333 deviceInstructionsDelivered: delivered.device,
2334 });
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}`;
2339 const images = yield* Effect.forEach(
2340 turnInput.message.attachments.filter(isProviderNativeImageAttachment),
2341 (attachment: ChatAttachment) =>
@@ -2354,12 +2372,10 @@ export const makeCursorAdapterV2 = Effect.fn("makeCursorAdapterV2")(function* (
2372 });
2373 }
2374 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 + };
2379 });
2380
2381 const startTurn = Effect.fn("CursorAdapterV2.startTurn")(
@@ -2390,13 +2406,15 @@ export const makeCursorAdapterV2 = Effect.fn("makeCursorAdapterV2")(function* (
2406 known?.agent === agent.nativeThreadId
2407 ? known
2408 : { orchestration: turnInput.runOrdinal > 1, device: false };
2393 - const message = yield* resolveUserMessage(
2409 + const interrupted = yield* Ref.get(interruptedPrompt);
2410 + const { message, prompt } = yield* resolveUserMessage(
2411 turnInput,
2412 mcpServers,
2413 hasDeviceTools,
2414 delivered,
2415 + interrupted?.agent === agent.nativeThreadId ? interrupted.text : undefined,
2416 );
2399 - const compacted = message === "/compress";
2417 + const compacted = prompt === undefined;
2418 const pendingUpdates: Array<InteractionUpdate> = [];
2419 let context: ActiveCursorTurn | null = null;
2420 // Create-time and send-time mcpServers merge with settingSources (SDK >= 1.0.39).
@@ -2424,6 +2442,9 @@ export const makeCursorAdapterV2 = Effect.fn("makeCursorAdapterV2")(function* (
2442 orchestration: !compacted && (delivered.orchestration || mcpServers !== undefined),
2443 device: !compacted && hasDeviceTools,
2444 });
2445 + if (!compacted) {
2446 + yield* Ref.set(interruptedPrompt, null);
2447 + }
2448 const startedAt = yield* DateTime.now;
2449 const completed = yield* Deferred.make<void, never>();
2450 const providerTurnId = idAllocator.derive.providerTurn({
@@ -2448,6 +2469,7 @@ export const makeCursorAdapterV2 = Effect.fn("makeCursorAdapterV2")(function* (
2469 current: null,
2470 nextSegment: 0,
2471 },
2472 + prompt,
2473 interrupted: false,
2474 finalized: false,
2475 turnEnded: false,