fix(cursor): retry prompts that only returned a transport failure #11225
Closedwhoislikemiha(GitHub profile, opens in a new tab)wants to merge 2 commits into
main fromrefs/pull/11225/headopened View on GitHubgithub-actions[bot](GitHub profile, opens in a new tab) added labelsvouch:unvouched
github-actions[bot](GitHub profile, opens in a new tab) added labelssize:L
- @@ -1078,0 +1126,21 @@1126+ // Retry only while the attempt produced nothing but the diagnostic;1127+ // a steer, a cancel, or any work leaves the failure to the check below.1128+ for (const delay of TRANSPORT_FAILURE_RETRY_DELAYS) {1129+ if (1130+ ctx.promptsInFlight !== 1 ||1131+ result.stopReason === "cancelled" ||1132+ failure === undefined ||1133+ !promptDidNoWork(ctx.promptActivity)1134+ ) {1135+ break;1136+ }1137+ yield* Effect.logWarning(1138+ "Cursor reported a transport failure before doing any work; retrying the prompt.",1139+ {1140+ threadId: input.threadId,1141+ turnId,1142+ failure,1143+ delayMs: Duration.toMillis(delay),1144+ },1145+ );1146+ const interrupted = yield* Deferred.await(ctx.turnInterrupted).pipe(@@ -1078,0 +1131,21 @@1131+ result.stopReason === "cancelled" ||1132+ failure === undefined ||1133+ !promptDidNoWork(ctx.promptActivity)1134+ ) {1135+ break;1136+ }1137+ yield* Effect.logWarning(1138+ "Cursor reported a transport failure before doing any work; retrying the prompt.",1139+ {1140+ threadId: input.threadId,1141+ turnId,1142+ failure,1143+ delayMs: Duration.toMillis(delay),1144+ },1145+ );1146+ const interrupted = yield* Deferred.await(ctx.turnInterrupted).pipe(1147+ Effect.as(true),1148+ Effect.timeoutOrElse({ duration: delay, orElse: () => Effect.succeed(false) }),1149+ );1150+ // A stop or a steer that landed during the backoff owns the turn now.1151+ if (ctx.stopped || ctx.promptsInFlight !== 1) {
- apps/server/src/provider/Layers/CursorAdapter.test.ts lines 339 to 351OutdatedResolvedby coderabbitai[bot](GitHub profile, opens in a new tab)@@ -197,0 +331,21 @@331+ threadId,332+ provider: ProviderDriverKind.make("cursor"),333+ cwd: process.cwd(),334+ runtimeMode: "full-access",335+ });336+ const sendTurnFiber = yield* adapter337+ .sendTurn({ threadId, input: "continue", attachments: [] })338+ .pipe(Effect.forkChild);339+ // The diagnostic is projected right before the adapter starts its backoff;340+ // 10ms hops stay well short of the first delay, so the interrupt below341+ // lands while the adapter is waiting to retry.342+ yield* Effect.gen(function* () {343+ for (let attempt = 0; attempt < 200; attempt += 1) {344+ if (yield* Deferred.isDone(sawDiagnostic)) {345+ return;346+ }347+ yield* TestClock.adjust("10 millis");348+ }349+ throw new Error("Timed out waiting for the mock agent's transport diagnostic.");350+ });351+ yield* adapter.interruptTurn(threadId);apps/server/src/provider/Layers/CursorAdapter.ts lines 1156 to 1159Resolvedby coderabbitai[bot](GitHub profile, opens in a new tab)@@ -1078,0 +1129,21 @@1129+ if (1130+ ctx.promptsInFlight !== 1 ||1131+ result.stopReason === "cancelled" ||1132+ failure === undefined ||1133+ !promptDidNoWork(ctx.promptActivity)1134+ ) {1135+ break;1136+ }1137+ yield* Effect.logWarning(1138+ "Cursor reported a transport failure before doing any work; retrying the prompt.",1139+ {1140+ threadId: input.threadId,1141+ turnId,1142+ failure,1143+ delayMs: Duration.toMillis(delay),1144+ },1145+ );1146+ const interrupted = yield* Deferred.await(ctx.turnInterrupted).pipe(1147+ Effect.as(true),1148+ Effect.timeoutOrElse({ duration: delay, orElse: () => Effect.succeed(false) }),1149+ );
juliusmarminge closed this
Sign in to join this conversation.
macroscopeapp[bot](GitHub profile, opens in a new tab) reviewed