@devries-cameron20 / t3code Mirror · read-only / commits / 656f3f4094
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 22, 19:30 UTC

fix(cursor): fail turns that end in a transport error after commentary (#23273)

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

Victor Vogel committed Oct 23, 2026 at 02:10 UTC 656f3f40945654f540a98b75ec11afff399e1baa
2 files changed +34 -8
packages/provider-cursor/src/server/adapter.test.ts
+28 -7
@@ -256,7 +256,23 @@ describe("CursorAdapterV2", () => {
256 "Cursor Agent SDK run.wait failed: Too many requests (resource_exhausted, HTTP 429)",
257 },
258 },
259 - ])("fails the turn with $reason", ({ wait, failure }) =>
259 + {
260 + reason: "a transport dump sent after earlier commentary",
261 + updates: [
262 + { type: "text-delta", text: "Checking the build first." },
263 + { type: "step-completed", stepId: 1, stepDurationMs: 1 },
264 + { type: "text-delta", text: "Error: RetriableError: WritableIterable is closed" },
265 + ] satisfies ReadonlyArray<InteractionUpdate>,
266 + wait: Effect.succeed({
267 + id: "native-cursor-run",
268 + requestId: "native-request",
269 + status: "finished" as const,
270 + model: { id: "claude-fable-5" },
271 + durationMs: 1,
272 + }),
273 + failure: { class: "transport_error", message: "Provider turn failed." },
274 + },
275 + ])("fails the turn with $reason", ({ updates = [], wait, failure }) =>
276 Effect.gen(function* () {
277 const fileSystem = yield* FileSystem.FileSystem;
278 const workspace = yield* fileSystem.makeTempDirectoryScoped({ prefix: "cursor-v2-failure-" });
@@ -280,12 +296,17 @@ describe("CursorAdapterV2", () => {
296 agentId: "native-cursor-failure",
297 listMessages: Effect.succeed([]),
298 close: Effect.void,
283 - send: () =>
284 - Effect.succeed({
285 - agentId: "native-cursor-failure",
286 - runId: "native-cursor-run",
287 - wait,
288 - cancel: Effect.void,
299 + send: (input) =>
300 + Effect.gen(function* () {
301 + for (const update of updates) {
302 + yield* input.onDelta!(update).pipe(Effect.orDie);
303 + }
304 + return {
305 + agentId: "native-cursor-failure",
306 + runId: "native-cursor-run",
307 + wait,
308 + cancel: Effect.void,
309 + };
310 }),
311 }),
312 }),
packages/provider-cursor/src/server/adapter.ts
+6 -1
@@ -867,7 +867,7 @@ interface ActiveCursorTurn {
867 readonly tools: Map<string, ActiveCursorToolCall>;
868 readonly subagents: Map<string, ActiveCursorSubagent>;
869 readonly assistant: ActiveCursorTextStream;
870 - readonly assistantReply: CursorTransportFailure;
870 + assistantReply: CursorTransportFailure;
871 readonly reasoning: ActiveCursorTextStream;
872 interrupted: boolean;
873 finalized: boolean;
@@ -1916,6 +1916,11 @@ export const makeCursorAdapterV2 = Effect.fn("makeCursorAdapterV2")(function* (
1916 }
1917 switch (update.type) {
1918 case "text-delta":
1919 + // Classify each assistant message on its own, so earlier
1920 + // commentary does not hide a later standalone transport dump.
1921 + if (context.assistant.current === null) {
1922 + context.assistantReply = new CursorTransportFailure();
1923 + }
1924 context.assistantReply.push(update.text);
1925 yield* completeReasoning(context);
1926 yield* appendTextSegment({