Skip to content

Commit 43cd198

Browse files
Merge remote-tracking branch 'origin/main' into fix/issue-24513
2 parents ca238a6 + 3afb9b3 commit 43cd198

3 files changed

Lines changed: 127 additions & 23 deletions

File tree

‎apps/server/src/preview/PreviewBrowser.ts‎

Lines changed: 17 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -25,31 +25,35 @@ import { openZipArchive } from "../zipArchive.ts";
2525
// https://googlechromelabs.github.io/chrome-for-testing/known-good-versions-with-downloads.json,
2626
// download each platform's chrome-headless-shell zip, and replace the version and every byte count
2727
// and SHA-256 below.
28-
const VERSION = "154.0.8037.92";
28+
//
29+
// The headless shell never loads Chrome's CRLSet, so a certificate block reaches it only through
30+
// Chromium's compiled-in SPKI blocklist. Do not pin below 156.0.8078.70: earlier builds trust the
31+
// compromised eMudhra intermediates (crrev.com/c/8627687).
32+
const VERSION = "156.0.8078.70";
2933
const ARCHIVES = {
3034
linux64: {
31-
bytes: 120_477_194,
32-
sha256: "636aa5c79f2693632e9921b8bbb050038ba11672e02346c06c20f991aed096f9",
35+
bytes: 126_646_931,
36+
sha256: "a313da592261ff1e342c1e507d315f25b1809006c0508f77ce86151d464d4ccb",
3337
},
3438
"linux-arm64": {
35-
bytes: 121_182_296,
36-
sha256: "0ed0e47d9e9f639197f508d62ada09e5c6b4c4c60edab3160a9312a733091df6",
39+
bytes: 126_749_876,
40+
sha256: "dca11213d2e0b1db52141edd9f92ec423fd52ca25715846790d84fa1d5d16e8a",
3741
},
3842
"mac-arm64": {
39-
bytes: 99_221_129,
40-
sha256: "77da14e75d7f2568e6f7898d3df7cdc6faac74b15e903b2c9d486ebb6ca9b929",
43+
bytes: 103_901_293,
44+
sha256: "1f848385611f2e58122e68969489712661880fc9a92c9dd20428099f9998ba7b",
4145
},
4246
"mac-x64": {
43-
bytes: 104_748_425,
44-
sha256: "a54292aaacbb77f76f6ef47558e7c51ab884044e0adacca315567f83c060bcc4",
47+
bytes: 109_387_968,
48+
sha256: "ab4cc2949f88439e2241b2712c49268f24982f2d25af87960466cc22bdc2e6e1",
4549
},
4650
win32: {
47-
bytes: 114_295_943,
48-
sha256: "56b30d2d6c35775ebf8dc3618680f6529e1c38c87f7feb28a16e9904273d51f7",
51+
bytes: 119_029_359,
52+
sha256: "37dc9a03f37fd79637fec9f26042bf32f04cfe5b83749d980eb1e7d1a429d47c",
4953
},
5054
win64: {
51-
bytes: 120_822_223,
52-
sha256: "3ac2561f02d9d87aadc0399d00b9002d718a4c365624fa67db9e7bfaf6b1a568",
55+
bytes: 126_214_071,
56+
sha256: "41c6aa97046d05d015b817a95f7b1512c3a1a41b18364f8da46478ae520400b1",
5357
},
5458
} as const;
5559

‎packages/provider-cursor/src/server/adapter.test.ts‎

Lines changed: 72 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -272,7 +272,62 @@ describe("CursorAdapterV2", () => {
272272
}),
273273
failure: { class: "transport_error", message: "Provider turn failed." },
274274
},
275-
])("fails the turn with $reason", ({ updates = [], wait, failure }) =>
275+
{
276+
reason: "no failure when Cursor's resume after the turn ended made no progress",
277+
// Cursor's SDK resumed from an older checkpoint after the answer was
278+
// delivered, regenerated the closing, then gave up on the run.
279+
updates: [
280+
{ type: "text-delta", text: "The answer." },
281+
{ type: "turn-ended" },
282+
{ type: "text-delta", text: "A regenerated closing." },
283+
{ type: "turn-ended" },
284+
] satisfies ReadonlyArray<InteractionUpdate>,
285+
wait: Effect.succeed({
286+
id: "native-cursor-run",
287+
requestId: "native-request",
288+
status: "error" as const,
289+
error: { message: "Agent turn stopped after repeated resume attempts made no progress" },
290+
model: { id: "claude-fable-5" },
291+
durationMs: 1,
292+
}),
293+
failure: null,
294+
},
295+
{
296+
reason: "the error a continuation after the turn ended stopped with",
297+
updates: [
298+
{ type: "text-delta", text: "The answer." },
299+
{ type: "turn-ended" },
300+
{ type: "text-delta", text: "Following up on the stop hook." },
301+
] satisfies ReadonlyArray<InteractionUpdate>,
302+
wait: Effect.succeed({
303+
id: "native-cursor-run",
304+
requestId: "native-request",
305+
status: "error" as const,
306+
error: { message: "Agent turn stopped after repeated resume attempts made no progress" },
307+
model: { id: "claude-fable-5" },
308+
durationMs: 1,
309+
}),
310+
failure: {
311+
class: "provider_error",
312+
message: "Agent turn stopped after repeated resume attempts made no progress",
313+
},
314+
},
315+
{
316+
reason: "no answer from a resume after the turn ended that made no progress",
317+
updates: [{ type: "turn-ended" }] 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+
result: "A regenerated closing.",
324+
model: { id: "claude-fable-5" },
325+
durationMs: 1,
326+
}),
327+
failure: null,
328+
answers: [],
329+
},
330+
])("ends the turn with $reason", ({ updates = [], wait, failure, answers }) =>
276331
Effect.gen(function* () {
277332
const fileSystem = yield* FileSystem.FileSystem;
278333
const workspace = yield* fileSystem.makeTempDirectoryScoped({ prefix: "cursor-v2-failure-" });
@@ -365,15 +420,23 @@ describe("CursorAdapterV2", () => {
365420
attachments: [],
366421
},
367422
});
368-
const terminal = yield* runtime.events.pipe(
369-
Stream.filter((event) => event.type === "turn.terminal"),
370-
Stream.runHead,
423+
const events = yield* runtime.events.pipe(
424+
Stream.takeUntil((event) => event.type === "turn.terminal"),
425+
Stream.runCollect,
371426
);
372-
assert.isTrue(Option.isSome(terminal));
373-
if (Option.isSome(terminal)) {
374-
assert.equal(terminal.value.status, "failed");
375-
assert.equal(terminal.value.failure?.class, failure.class);
376-
assert.equal(terminal.value.failure?.message, failure.message);
427+
const terminal = events.find((event) => event.type === "turn.terminal");
428+
assert.equal(terminal?.status, failure === null ? "completed" : "failed");
429+
assert.equal(terminal?.failure?.class, failure?.class);
430+
assert.equal(terminal?.failure?.message, failure?.message);
431+
if (answers !== undefined) {
432+
assert.deepEqual(
433+
events.flatMap((event) =>
434+
event.type === "message.updated" && event.message.role === "assistant"
435+
? [event.message.text]
436+
: [],
437+
),
438+
answers,
439+
);
377440
}
378441
}).pipe(
379442
Effect.scoped,

‎packages/provider-cursor/src/server/adapter.ts‎

Lines changed: 38 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -824,6 +824,11 @@ interface CursorProjectionTarget {
824824
// Fallback final output when Cursor's result carries none. The persisted row only
825825
// ever shows a bounded tail, so keep a little more than that.
826826
const MAX_CURSOR_STREAMED_OUTPUT_CHARS = 256 * 1024;
827+
// After a turn ends, a retryable stream error can make Cursor's SDK resume from
828+
// an older checkpoint inside the same run. When those resumes save nothing, it
829+
// ends the run with this error even though the answer was already delivered.
830+
const CURSOR_RESUME_NO_PROGRESS_MESSAGE =
831+
"Agent turn stopped after repeated resume attempts made no progress";
827832

828833
interface ActiveCursorToolCall {
829834
readonly callId: string;
@@ -871,6 +876,8 @@ interface ActiveCursorTurn {
871876
readonly reasoning: ActiveCursorTextStream;
872877
interrupted: boolean;
873878
finalized: boolean;
879+
/** The agent's latest turn ended and no new work has started since. */
880+
turnEnded: boolean;
874881
}
875882

876883
interface CursorLiveAgent {
@@ -1914,6 +1921,18 @@ export const makeCursorAdapterV2 = Effect.fn("makeCursorAdapterV2")(function* (
19141921
if (context.finalized) {
19151922
return;
19161923
}
1924+
if (update.type === "turn-ended") {
1925+
context.turnEnded = true;
1926+
} else if (
1927+
update.type === "step-started" ||
1928+
update.type === "user-message-appended" ||
1929+
update.type === "text-delta" ||
1930+
update.type === "thinking-delta" ||
1931+
update.type === "partial-tool-call" ||
1932+
update.type === "tool-call-started"
1933+
) {
1934+
context.turnEnded = false;
1935+
}
19171936
switch (update.type) {
19181937
case "text-delta":
19191938
// Classify each assistant message on its own, so earlier
@@ -2099,6 +2118,11 @@ export const makeCursorAdapterV2 = Effect.fn("makeCursorAdapterV2")(function* (
20992118
yield* Deferred.succeed(input.context.completed, undefined);
21002119
});
21012120

2121+
const isResumeFailureAfterTurnEnded = (context: ActiveCursorTurn, result: RunResult) =>
2122+
context.turnEnded &&
2123+
result.status === "error" &&
2124+
result.error?.message === CURSOR_RESUME_NO_PROGRESS_MESSAGE;
2125+
21022126
const terminalStatus = (
21032127
context: ActiveCursorTurn,
21042128
result: RunResult,
@@ -2115,7 +2139,7 @@ export const makeCursorAdapterV2 = Effect.fn("makeCursorAdapterV2")(function* (
21152139
case "cancelled":
21162140
return "cancelled";
21172141
case "error":
2118-
return "failed";
2142+
return isResumeFailureAfterTurnEnded(context, result) ? "completed" : "failed";
21192143
}
21202144
};
21212145

@@ -2319,6 +2343,7 @@ export const makeCursorAdapterV2 = Effect.fn("makeCursorAdapterV2")(function* (
23192343
},
23202344
interrupted: false,
23212345
finalized: false,
2346+
turnEnded: false,
23222347
};
23232348
yield* Ref.set(activeTurn, context);
23242349
yield* emitProviderEvent({
@@ -2350,6 +2375,8 @@ export const makeCursorAdapterV2 = Effect.fn("makeCursorAdapterV2")(function* (
23502375
if (
23512376
context !== null &&
23522377
context.assistant.nextSegment === 0 &&
2378+
// Text from a resume that made no progress is not the turn's answer.
2379+
!isResumeFailureAfterTurnEnded(context, result) &&
23532380
result.result !== undefined &&
23542381
result.result.length > 0
23552382
) {
@@ -2361,6 +2388,16 @@ export const makeCursorAdapterV2 = Effect.fn("makeCursorAdapterV2")(function* (
23612388
text: result.result,
23622389
});
23632390
}
2391+
if (context !== null && isResumeFailureAfterTurnEnded(context, result)) {
2392+
yield* Effect.logWarning(
2393+
"orchestration-v2.cursor-resume-failed-after-turn-ended",
2394+
{
2395+
providerSessionId: input.providerSessionId,
2396+
providerThreadId: turnInput.providerThread.id,
2397+
providerTurnId,
2398+
},
2399+
);
2400+
}
23642401
if (context !== null) {
23652402
const transportFailure = context.assistantReply.failure;
23662403
const status =

0 commit comments

Comments
 (0)