@devries-cameron20 / t3code Mirror · read-only / commits / ed203c46cb
Fork 0

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

Mirrored from https://github.com/Camo67/t3code.git

Synced Nov 21, 04:45 UTC

fix(cursor): stop repeating runtime instructions on every turn (#39605)

Co-authored-by: Cursor <cursoragent@cursor.com> Co-authored-by: Julius Marminge <julius0216@outlook.com> Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>

Yash Singh committed Nov 20, 2026 at 03:02 UTC ed203c46cb3d6d1d53dd85ac58852425b8434b6a
3 files changed +352 -39
apps/server/src/orchestration-v2/testkit/ReplayRuntimeInstructions.ts
+121 -10
@@ -56,12 +56,71 @@ export function materializeReplayTranscriptRuntimeInstructions(
56 }
57 | undefined;
58 let pendingKiroCompact: { readonly sessionId: unknown } | undefined;
59 + const cursorSessionKey = "cursor";
60 + let cursorAgentId: string | undefined;
61 + let interruptedCursorNotes:
62 + | {
63 + readonly agentId: string | undefined;
64 + readonly notes: string;
65 + }
66 + | undefined;
67 + let pendingCursorRun:
68 + | {
69 + readonly notes: string | undefined;
70 + readonly compact: boolean;
71 + compacted: boolean;
72 + }
73 + | undefined;
74
75 return {
76 ...transcript,
77 entries: transcript.entries.map((entry) => {
78 if (entry.type === "emit_inbound") {
79 const frame = asFrame(entry.frame);
80 + if (runtime.driver === "cursor") {
81 + if (
82 + (frame?.type === "agent.opened" || frame?.type === "run.started") &&
83 + typeof frame.agentId === "string"
84 + ) {
85 + cursorAgentId = frame.agentId;
86 + }
87 + const cursorUpdate =
88 + frame?.type === "interaction.update" && isRecord(frame.update)
89 + ? frame.update
90 + : undefined;
91 + if (cursorUpdate?.type === "summary-completed" && cursorUpdate.failed !== true) {
92 + deliveredNotes.delete(cursorSessionKey);
93 + if (interruptedCursorNotes?.agentId === cursorAgentId) {
94 + interruptedCursorNotes = undefined;
95 + }
96 + if (pendingCursorRun !== undefined) pendingCursorRun.compacted = true;
97 + }
98 + if (frame?.type === "run.completed" && pendingCursorRun !== undefined) {
99 + const status = isRecord(frame.result) ? frame.result.status : undefined;
100 + if (pendingCursorRun.compact) {
101 + deliveredNotes.delete(cursorSessionKey);
102 + } else if (
103 + status === "finished" &&
104 + !pendingCursorRun.compacted &&
105 + pendingCursorRun.notes !== undefined
106 + ) {
107 + deliveredNotes.set(cursorSessionKey, pendingCursorRun.notes);
108 + interruptedCursorNotes = undefined;
109 + } else if (status !== "finished") {
110 + if (pendingCursorRun.notes !== undefined) {
111 + deliveredNotes.delete(cursorSessionKey);
112 + }
113 + interruptedCursorNotes =
114 + status === "cancelled" &&
115 + !pendingCursorRun.compacted &&
116 + pendingCursorRun.notes !== undefined
117 + ? { agentId: cursorAgentId, notes: pendingCursorRun.notes }
118 + : undefined;
119 + }
120 + pendingCursorRun = undefined;
121 + }
122 + return entry;
123 + }
124 if (frame?.kind === "response" && frame.method === "session/prompt" && pendingPrompt) {
125 const stopReason = isRecord(frame.result) ? frame.result.stopReason : undefined;
126 const delivered =
@@ -119,16 +178,65 @@ export function materializeReplayTranscriptRuntimeInstructions(
178 if (entry.type !== "expect_outbound") return entry;
179 const frame = entry.frame;
180 if (typeof frame !== "object" || frame === null) return entry;
122 - if (
123 - runtime.driver === "cursor" &&
124 - "type" in frame &&
125 - frame.type === "run.start" &&
126 - "message" in frame &&
127 - typeof frame.message === "string"
128 - ) {
129 - return frame.message.endsWith(instructions)
130 - ? entry
131 - : { ...entry, frame: { ...frame, message: `${frame.message}\n\n${instructions}` } };
181 + if (runtime.driver === "cursor" && "type" in frame) {
182 + if (frame.type === "agent.close") {
183 + deliveredNotes.clear();
184 + cursorAgentId = undefined;
185 + interruptedCursorNotes = undefined;
186 + pendingCursorRun = undefined;
187 + return entry;
188 + }
189 + if (frame.type === "run.resume") {
190 + pendingCursorRun = {
191 + notes:
192 + interruptedCursorNotes !== undefined &&
193 + interruptedCursorNotes.agentId === cursorAgentId
194 + ? interruptedCursorNotes.notes
195 + : undefined,
196 + compact: false,
197 + compacted: false,
198 + };
199 + return entry;
200 + }
201 + if (frame.type === "run.start") {
202 + if (
203 + ("summarize" in frame && frame.summarize === true) ||
204 + ("message" in frame &&
205 + typeof frame.message === "string" &&
206 + frame.message.trim() === "/compress")
207 + ) {
208 + deliveredNotes.delete(cursorSessionKey);
209 + pendingCursorRun = { notes: undefined, compact: true, compacted: false };
210 + return entry;
211 + }
212 + if ("message" in frame && typeof frame.message === "string") {
213 + const options =
214 + "options" in frame && isRecord(frame.options) ? frame.options : undefined;
215 + const model =
216 + isRecord(options?.model) && typeof options.model.id === "string"
217 + ? options.model.id
218 + : runtime.model;
219 + const expected =
220 + model === runtime.model ? instructions : buildRuntimeInstructions({ harness, model });
221 + const recorded = frame.message.endsWith(expected);
222 + const resend = !recorded && deliveredNotes.get(cursorSessionKey) !== expected;
223 + interruptedCursorNotes = undefined;
224 + pendingCursorRun = {
225 + notes: recorded || resend ? expected : undefined,
226 + compact: false,
227 + compacted: false,
228 + };
229 + if (!resend) return entry;
230 + return {
231 + ...entry,
232 + frame: {
233 + ...frame,
234 + message: frame.message.length === 0 ? expected : `${frame.message}\n\n${expected}`,
235 + },
236 + };
237 + }
238 + }
239 + return entry;
240 }
241 if (
242 "method" in frame &&
@@ -235,8 +343,11 @@ function promptPartText(part: unknown): string | undefined {
343
344 type ReplayFrame = {
345 readonly kind?: unknown;
346 + readonly type?: unknown;
347 + readonly agentId?: unknown;
348 readonly method?: unknown;
349 readonly params?: unknown;
350 + readonly update?: unknown;
351 readonly result?: unknown;
352 readonly error?: unknown;
353 };
packages/provider-cursor/src/server/adapter.test.ts
+155 -22
@@ -762,6 +762,8 @@ describe("CursorAdapterV2", () => {
762 const sentMessages: Array<string> = [];
763 const rewoundAfter: Array<string> = [];
764 let rewindFails = false;
765 + let nextRunStatus: "finished" | "error" = "finished";
766 + let nextSummaryCompleted: { readonly failed?: boolean } | undefined;
767 let createdAgents = 0;
768 const instanceId = ProviderInstanceId.make("cursor");
769 const threadId = ThreadId.make("cursor-device-thread");
@@ -810,15 +812,28 @@ describe("CursorAdapterV2", () => {
812 typeof input.message === "string" ? input.message : input.message.text,
813 );
814 const runId = `native-cursor-run-${sentMessages.length}`;
815 + const status = nextRunStatus;
816 + const summaryCompleted = nextSummaryCompleted;
817 + nextRunStatus = "finished";
818 + nextSummaryCompleted = undefined;
819 return {
820 agentId,
821 runId,
816 - wait: Effect.succeed({
817 - id: runId,
818 - requestId: `native-request-${sentMessages.length}`,
819 - status: "finished" as const,
820 - model: { id: "composer-2.5" },
821 - durationMs: 1,
822 + wait: Effect.gen(function* () {
823 + if (summaryCompleted !== undefined) {
824 + yield* input.onDelta!({
825 + type: "summary-completed",
826 + ...summaryCompleted,
827 + }).pipe(Effect.orDie);
828 + }
829 + return {
830 + id: runId,
831 + requestId: `native-request-${sentMessages.length}`,
832 + status,
833 + ...(status === "error" ? { error: { message: "transient failure" } } : {}),
834 + model: { id: input.options?.model?.id ?? "composer-2.5" },
835 + durationMs: 1,
836 + };
837 }),
838 cancel: Effect.void,
839 };
@@ -866,12 +881,24 @@ describe("CursorAdapterV2", () => {
881 // Starts at run 5: a conversation from before device instructions existed, now resumed.
882 let runOrdinal = 4;
883 let lastProviderTurn: OrchestrationV2ProviderTurn | undefined;
869 - const send = Effect.fnUntraced(function* (compact = false, nativeThreadHasTurns?: boolean) {
884 + const send = Effect.fnUntraced(function* (
885 + compact = false,
886 + nativeThreadHasTurns?: boolean,
887 + options?: {
888 + readonly model?: string;
889 + readonly status?: "finished" | "error";
890 + readonly summaryCompleted?: { readonly failed?: boolean };
891 + },
892 + ) {
893 runOrdinal += 1;
894 + nextRunStatus = options?.status ?? "finished";
895 + nextSummaryCompleted = options?.summaryCompleted;
896 + const turnModelSelection =
897 + options?.model === undefined ? modelSelection : { instanceId, model: options.model };
898 const turnInput = {
899 threadId,
900 providerThread,
874 - modelSelection,
901 + modelSelection: turnModelSelection,
902 runtimePolicy,
903 ...(nativeThreadHasTurns === undefined ? {} : { nativeThreadHasTurns }),
904 runId: RunId.make(`cursor-device-run-${runOrdinal}`),
@@ -900,27 +927,88 @@ describe("CursorAdapterV2", () => {
927 return {
928 orchestration: sent.includes("## T3 Code orchestration"),
929 devices: sent.includes("## T3 Code devices"),
930 + runtime: sent.includes("<runtime_info>"),
931 };
932 });
905 - const told = (orchestration: boolean, devices: boolean) => ({ orchestration, devices });
933 + const told = (orchestration: boolean, devices: boolean, runtime: boolean) => ({
934 + orchestration,
935 + devices,
936 + runtime,
937 + });
938
939 yield* setDeviceAccess(true);
908 - assert.deepEqual(yield* send(), told(false, true));
909 - assert.deepEqual(yield* send(), told(false, false));
940 + assert.deepEqual(yield* send(), told(false, true, true));
941 + assert.deepEqual(yield* send(), told(false, false, false));
942 yield* send(true);
943 assert.deepEqual(
944 yield* send(),
913 - told(true, true),
945 + told(true, true, true),
946 "compaction drops what the conversation was told",
947 );
948 yield* setDeviceAccess(false);
917 - assert.deepEqual(yield* send(), told(false, false));
949 + assert.deepEqual(yield* send(), told(false, false, false));
950 yield* setDeviceAccess(true);
919 - assert.deepEqual(yield* send(), told(false, true), "device access turned on later");
920 - assert.deepEqual(yield* send(), told(false, false));
951 + assert.deepEqual(yield* send(), told(false, true, false), "device access turned on later");
952 + assert.deepEqual(yield* send(), told(false, false, false));
953 +
954 + assert.deepEqual(
955 + yield* send(false, undefined, { model: "gemini-4-neon", status: "error" }),
956 + told(false, false, true),
957 + "a model change resends runtime instructions",
958 + );
959 + assert.deepEqual(
960 + yield* send(),
961 + told(false, false, true),
962 + "reverting after a failed model-change run resends runtime instructions",
963 + );
964 + assert.include(sentMessages.at(-1)!, "as composer-2.5");
965 + assert.deepEqual(
966 + yield* send(false, undefined, { status: "error" }),
967 + told(false, false, false),
968 + "an unchanged turn omits runtime instructions even when it fails",
969 + );
970 + assert.deepEqual(
971 + yield* send(),
972 + told(false, false, false),
973 + "a failed unchanged turn keeps delivered runtime instructions",
974 + );
975 + assert.deepEqual(
976 + yield* send(false, undefined, { model: "gemini-4-neon", status: "error" }),
977 + told(false, false, true),
978 + );
979 + assert.deepEqual(
980 + yield* send(false, undefined, { model: "gemini-4-neon" }),
981 + told(false, false, true),
982 + "a failed turn does not record runtime instructions as delivered",
983 + );
984 + assert.include(sentMessages.at(-1)!, "as gemini-4-neon");
985 + assert.deepEqual(
986 + yield* send(false, undefined, {
987 + model: "gemini-4-neon",
988 + summaryCompleted: { failed: true },
989 + }),
990 + told(false, false, false),
991 + );
992 + assert.deepEqual(
993 + yield* send(false, undefined, {
994 + model: "gemini-4-neon",
995 + summaryCompleted: {},
996 + }),
997 + told(false, false, false),
998 + "a failed auto-compaction keeps delivered instructions",
999 + );
1000 + assert.deepEqual(
1001 + yield* send(false, undefined, { model: "gemini-4-neon" }),
1002 + told(true, true, true),
1003 + "auto-compaction drops what the conversation was told",
1004 + );
1005 + assert.deepEqual(
1006 + yield* send(false, undefined, { model: "gemini-4-neon" }),
1007 + told(false, false, false),
1008 + );
1009
1010 const keptTurn = lastProviderTurn!;
923 - yield* send();
1011 + yield* send(false, undefined, { model: "gemini-4-neon" });
1012 const rollbackToKept = runtime.rollbackThread({
1013 providerThread,
1014 target: {
@@ -935,8 +1023,8 @@ describe("CursorAdapterV2", () => {
1023 yield* Effect.flip(rollbackToKept);
1024 rewindFails = false;
1025 assert.deepEqual(
938 - yield* send(false, true),
939 - told(false, false),
1026 + yield* send(false, true, { model: "gemini-4-neon" }),
1027 + told(false, false, false),
1028 "a failed rewind leaves the conversation, and what it was told, unchanged",
1029 );
1030 const rewound = yield* rollbackToKept;
@@ -947,8 +1035,8 @@ describe("CursorAdapterV2", () => {
1035 "Cursor rewinds the same agent",
1036 );
1037 assert.deepEqual(
950 - yield* send(false, true),
951 - told(true, true),
1038 + yield* send(false, true, { model: "gemini-4-neon" }),
1039 + told(true, true, true),
1040 "the rewound conversation may have dropped instructions a later turn carried",
1041 );
1042
@@ -969,8 +1057,8 @@ describe("CursorAdapterV2", () => {
1057 );
1058 providerThread = rolledBack.providerThread;
1059 assert.deepEqual(
972 - yield* send(false, false),
973 - told(true, true),
1060 + yield* send(false, false, { model: "gemini-4-neon" }),
1061 + told(true, true, true),
1062 "the fresh agent after a rollback has been told nothing",
1063 );
1064 }).pipe(
@@ -990,6 +1078,7 @@ describe("CursorAdapterV2", () => {
1078 // Cursor keeps a cancelled run in the conversation only once it saved a checkpoint.
1079 const checkpointedRuns = new Set<string>();
1080 const runEnds: Array<Deferred.Deferred<"finished" | "cancelled">> = [];
1081 + const runDeltas: Array<(update: InteractionUpdate) => Effect.Effect<void>> = [];
1082 const instanceId = ProviderInstanceId.make("cursor");
1083 const threadId = ThreadId.make("cursor-steer-thread");
1084 const modelSelection = { instanceId, model: "composer-2.5" };
@@ -1024,6 +1113,7 @@ describe("CursorAdapterV2", () => {
1113 const runId = `native-cursor-run-${sentMessages.length}`;
1114 const ended = yield* Deferred.make<"finished" | "cancelled">();
1115 runEnds.push(ended);
1116 + runDeltas.push((update) => input.onDelta!(update).pipe(Effect.orDie));
1117 return {
1118 agentId: "native-cursor-steer",
1119 runId,
@@ -1138,6 +1228,11 @@ describe("CursorAdapterV2", () => {
1228 firstPrompt,
1229 "the interrupted prompt is missing from the run that replaces it",
1230 );
1231 + assert.include(
1232 + steered,
1233 + "<runtime_info>",
1234 + "an interrupted first run did not deliver runtime instructions",
1235 + );
1236
1237 yield* Deferred.succeed(runEnds[1]!, "finished");
1238 yield* runtime.events.pipe(
@@ -1146,6 +1241,11 @@ describe("CursorAdapterV2", () => {
1241 );
1242 yield* runtime.startTurn(turnInput(3, "Now a cow."));
1243 assert.notInclude(sentMessages[2]!, firstPrompt, "a finished turn carries nothing forward");
1244 + assert.notInclude(
1245 + sentMessages[2]!,
1246 + "<runtime_info>",
1247 + "a finished turn delivered runtime instructions",
1248 + );
1249
1250 const interruptRunning = Effect.gen(function* () {
1251 const running = Option.getOrThrow(
@@ -1199,6 +1299,39 @@ describe("CursorAdapterV2", () => {
1299 yield* interruptRunning;
1300 yield* runtime.resumeTurn!(resumeInput(9));
1301 assert.deepEqual(resumedRuns, [5, 6, 8, 9]);
1302 +
1303 + // Compaction before a checkpointed stop invalidates the interrupted run's runtime instructions,
1304 + // so a subsequent native resume completion must not suppress them on the follow-up turn.
1305 + yield* Deferred.succeed(runEnds[8]!, "finished");
1306 + yield* runtime.events.pipe(
1307 + Stream.filter((event) => event.type === "turn.terminal" && event.status === "completed"),
1308 + Stream.runHead,
1309 + );
1310 + const neonSelection = { instanceId, model: "gemini-4-neon" };
1311 + yield* runtime.startTurn({
1312 + ...turnInput(10, "Switch model."),
1313 + modelSelection: neonSelection,
1314 + });
1315 + assert.include(sentMessages[9]!, "as gemini-4-neon");
1316 + yield* runDeltas[9]!({ type: "summary-completed" });
1317 + checkpointedRuns.add("native-cursor-run-10");
1318 + yield* interruptRunning;
1319 + yield* runtime.resumeTurn!({ ...resumeInput(11), modelSelection: neonSelection });
1320 + assert.strictEqual(sentMessages[10], "");
1321 + yield* Deferred.succeed(runEnds[10]!, "finished");
1322 + yield* runtime.events.pipe(
1323 + Stream.filter((event) => event.type === "turn.terminal" && event.status === "completed"),
1324 + Stream.runHead,
1325 + );
1326 + yield* runtime.startTurn({
1327 + ...turnInput(12, "After resume."),
1328 + modelSelection: neonSelection,
1329 + });
1330 + assert.include(
1331 + sentMessages[11]!,
1332 + "as gemini-4-neon",
1333 + "native resume after compaction must not mark invalidated runtime instructions delivered",
1334 + );
1335 }).pipe(
1336 Effect.scoped,
1337 Effect.provide(
packages/provider-cursor/src/server/adapter.ts
+76 -7
@@ -980,6 +980,8 @@ interface ActiveCursorTurn {
980 /** The user text this run sent, before runtime instructions; absent for /compress and resume. */
981 readonly prompt: string | undefined;
982 readonly message: string | SDKUserMessage;
983 + readonly runtimeInstructions: string | undefined;
984 + compacted: boolean;
985 interrupted: boolean;
986 finalized: boolean;
987 /** The agent's latest turn ended and no new work has started since. */
@@ -1063,6 +1065,7 @@ export const makeCursorAdapterV2 = Effect.fn("makeCursorAdapterV2")(function* (
1065 readonly agent: string;
1066 readonly orchestration: boolean;
1067 readonly device: boolean;
1068 + readonly runtime: string | undefined;
1069 } | null>(null);
1070 // Cursor drops a run cancelled before its first checkpoint, so the next message carries its prompt.
1071 const interruptedPrompt = yield* Ref.make<{
@@ -1070,6 +1073,7 @@ export const makeCursorAdapterV2 = Effect.fn("makeCursorAdapterV2")(function* (
1073 readonly runId: string;
1074 readonly text: string;
1075 readonly message: string | SDKUserMessage;
1076 + readonly runtimeInstructions: string | undefined;
1077 } | null>(null);
1078 // A native resume's own run may stop before it checkpoints; the request is still in history.
1079 const resumedAgent = yield* Ref.make<string | null>(null);
@@ -2280,6 +2284,22 @@ export const makeCursorAdapterV2 = Effect.fn("makeCursorAdapterV2")(function* (
2284 yield* completeAssistant(context);
2285 yield* completeReasoning(context);
2286 return;
2287 + case "summary-completed":
2288 + if (update.failed !== true) {
2289 + context.compacted = true;
2290 + yield* Ref.set(told, {
2291 + agent: context.run.agentId,
2292 + orchestration: false,
2293 + device: false,
2294 + runtime: undefined,
2295 + });
2296 + yield* Ref.update(interruptedPrompt, (current) =>
2297 + current?.agent === context.run.agentId
2298 + ? { ...current, runtimeInstructions: undefined }
2299 + : current,
2300 + );
2301 + }
2302 + return;
2303 case "shell-output-delta": {
2304 const toolCallId = update.event.toolCallId;
2305 const shell =
@@ -2463,12 +2483,26 @@ export const makeCursorAdapterV2 = Effect.fn("makeCursorAdapterV2")(function* (
2483 threadDisposition,
2484 },
2485 );
2486 + if (input.context.runtimeInstructions !== undefined) {
2487 + const deliveredRuntime =
2488 + input.status === "completed" && !input.context.compacted
2489 + ? input.context.runtimeInstructions
2490 + : undefined;
2491 + yield* Ref.update(told, (current) =>
2492 + current?.agent === input.context.run.agentId
2493 + ? { ...current, runtime: deliveredRuntime }
2494 + : current,
2495 + );
2496 + }
2497 if (input.status === "interrupted" && input.context.prompt !== undefined) {
2498 yield* Ref.set(interruptedPrompt, {
2499 agent: input.context.run.agentId,
2500 runId: input.context.run.runId,
2501 text: input.context.prompt,
2502 message: input.context.message,
2503 + runtimeInstructions: input.context.compacted
2504 + ? undefined
2505 + : input.context.runtimeInstructions,
2506 });
2507 }
2508 yield* Ref.update(activeTurn, (current) =>
@@ -2623,12 +2657,16 @@ export const makeCursorAdapterV2 = Effect.fn("makeCursorAdapterV2")(function* (
2657 turnInput: ProviderAdapter.ProviderAdapterV2TurnInput,
2658 mcpServers: Record<string, McpServerConfig> | undefined,
2659 hasDeviceTools: boolean,
2626 - delivered: { readonly orchestration: boolean; readonly device: boolean },
2660 + delivered: {
2661 + readonly orchestration: boolean;
2662 + readonly device: boolean;
2663 + readonly runtime: string | undefined;
2664 + },
2665 interrupted: string | undefined,
2666 ) {
2667 const rawText = turnInput.message.text;
2668 if (rawText.trim() === "/compress" && turnInput.message.attachments.length === 0) {
2631 - return { message: "/compress", prompt: undefined };
2669 + return { message: "/compress", prompt: undefined, runtimeInstructions: undefined };
2670 }
2671 const newText = t3OrchestrationPrompt({
2672 prompt: yield* providerMessageTextWithAttachmentPaths({
@@ -2684,10 +2722,21 @@ export const makeCursorAdapterV2 = Effect.fn("makeCursorAdapterV2")(function* (
2722 detail: "Cursor turn requires non-empty text or attachments.",
2723 });
2724 }
2687 - const text = `${userText}\n\n${buildRuntimeInstructions({ harness: "Cursor", model: turnInput.modelSelection.model })}`;
2725 + const runtimeInstructions = buildRuntimeInstructions({
2726 + harness: "Cursor",
2727 + model: turnInput.modelSelection.model,
2728 + });
2729 + // Resend only on a new/compacted/rewound conversation or when the model changes.
2730 + const sendRuntimeInstructions = delivered.runtime !== runtimeInstructions;
2731 + const text = sendRuntimeInstructions
2732 + ? userText.length === 0
2733 + ? runtimeInstructions
2734 + : `${userText}\n\n${runtimeInstructions}`
2735 + : userText;
2736 return {
2737 message: images.length === 0 ? text : ({ text, images } satisfies SDKUserMessage),
2738 prompt: userText,
2739 + runtimeInstructions: sendRuntimeInstructions ? runtimeInstructions : undefined,
2740 };
2741 });
2742
@@ -2722,6 +2771,7 @@ export const makeCursorAdapterV2 = Effect.fn("makeCursorAdapterV2")(function* (
2771 : {
2772 orchestration: turnInput.nativeThreadHasTurns ?? turnInput.runOrdinal > 1,
2773 device: false,
2774 + runtime: undefined,
2775 };
2776 const interrupted = yield* Ref.get(interruptedPrompt);
2777 const runCheckpointed = (runId?: string) =>
@@ -2749,11 +2799,22 @@ export const makeCursorAdapterV2 = Effect.fn("makeCursorAdapterV2")(function* (
2799 providerThreadId: turnInput.providerThread.id,
2800 });
2801 }
2752 - const { message, prompt } =
2802 + const { message, prompt, runtimeInstructions } =
2803 resume === "native"
2754 - ? { message: "", prompt: undefined }
2804 + ? {
2805 + message: "",
2806 + prompt: undefined,
2807 + runtimeInstructions:
2808 + interrupted?.agent === agent.nativeThreadId
2809 + ? interrupted.runtimeInstructions
2810 + : undefined,
2811 + }
2812 : resume === "replay"
2756 - ? { message: dropped!.message, prompt: dropped!.text }
2813 + ? {
2814 + message: dropped!.message,
2815 + prompt: dropped!.text,
2816 + runtimeInstructions: dropped!.runtimeInstructions,
2817 + }
2818 : yield* resolveUserMessage(
2819 turnInput,
2820 mcpServers,
@@ -2802,6 +2863,7 @@ export const makeCursorAdapterV2 = Effect.fn("makeCursorAdapterV2")(function* (
2863 agent: agent.nativeThreadId,
2864 orchestration: !compacted && (delivered.orchestration || mcpServers !== undefined),
2865 device: !compacted && hasDeviceTools,
2866 + runtime: compacted ? undefined : delivered.runtime,
2867 });
2868 }
2869 if (!compacted && resume !== "native") {
@@ -2836,6 +2898,8 @@ export const makeCursorAdapterV2 = Effect.fn("makeCursorAdapterV2")(function* (
2898 },
2899 prompt,
2900 message,
2901 + runtimeInstructions,
2902 + compacted,
2903 interrupted: false,
2904 finalized: false,
2905 turnEnded: false,
@@ -3268,7 +3332,12 @@ export const makeCursorAdapterV2 = Effect.fn("makeCursorAdapterV2")(function* (
3332 // The kept turns may predate a compaction, so the instructions are sent again.
3333 const forgetConversation = (agent: string) =>
3334 Effect.all([
3271 - Ref.set(told, { agent, orchestration: false, device: false }),
3335 + Ref.set(told, {
3336 + agent,
3337 + orchestration: false,
3338 + device: false,
3339 + runtime: undefined,
3340 + }),
3341 Ref.set(interruptedPrompt, null),
3342 Ref.set(resumedAgent, null),
3343 ]);