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, 09:30 UTC
fix(cursor): avoid reporting unfinished tool calls as successful (#21448)
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com> Co-authored-by: maria-rcks <maria@kuuro.net>
Victor Vogel committed
Oct 31, 2026 at 21:20 UTC
481ff3ea89c7358953e8b7ffb762978c31fb3a0b
2 files changed
+65
-2
packages/provider-cursor/src/server/adapter.test.ts
+63
-1
@@ -43,7 +43,7 @@ describe("CursorAdapterV2", () => {
43
{ status: "finished", model: undefined, lateModel: "gpt-6-sol" },
44
{ status: "finished", model: "gpt-6-sol", lateModel: null },
45
] as const)(
46
- "projects Cursor tasks: $status, late model $lateModel",
46
+ "projects Cursor tasks and unfinished tools: $status, late model $lateModel",
47
({ status, model, lateModel }) =>
48
Effect.gen(function* () {
49
const fileSystem = yield* FileSystem.FileSystem;
@@ -115,6 +115,34 @@ describe("CursorAdapterV2", () => {
115
},
116
}).pipe(Effect.orDie);
117
}
118
+ const readUpdates: ReadonlyArray<InteractionUpdate> = [
119
+ {
120
+ type: "tool-call-started",
121
+ modelCallId: "native-model-call",
122
+ callId: "read-secret",
123
+ toolCall: { type: "read", args: { path: "secret.txt" } },
124
+ },
125
+ ...(["tool-call-started", "tool-call-completed"] as const).map((type) => ({
126
+ type,
127
+ modelCallId: "native-model-call",
128
+ callId: "read-open",
129
+ toolCall: {
130
+ type: "read" as const,
131
+ args: { path: "open.txt" },
132
+ ...(type === "tool-call-completed"
133
+ ? {
134
+ result: {
135
+ status: "success" as const,
136
+ value: { fileSize: 3, content: "ok\n", totalLines: 1 },
137
+ },
138
+ }
139
+ : {}),
140
+ },
141
+ })),
142
+ ];
143
+ for (const update of readUpdates) {
144
+ yield* input.onDelta!(update).pipe(Effect.orDie);
145
+ }
146
return {
147
agentId: "native-cursor-lifecycle",
148
runId: "native-cursor-run",
@@ -205,6 +233,40 @@ describe("CursorAdapterV2", () => {
233
: "failed",
234
);
235
assert.isNotNull(rows.at(-1)?.subagent.completedAt);
236
+ const unfinished =
237
+ status === "finished" ? "interrupted" : status === "error" ? "failed" : "cancelled";
238
+ const finalReads = new Map<string, { status: string; output: unknown; done: boolean }>();
239
+ for (const event of events) {
240
+ if (
241
+ event.type === "turn_item.updated" &&
242
+ event.turnItem.type === "dynamic_tool" &&
243
+ event.turnItem.toolName === "Read"
244
+ ) {
245
+ finalReads.set(String(event.turnItem.title), {
246
+ status: event.turnItem.status,
247
+ output: event.turnItem.output,
248
+ done: event.turnItem.completedAt !== null,
249
+ });
250
+ }
251
+ }
252
+ const finalNodes = new Map<string, string>();
253
+ for (const event of events) {
254
+ if (event.type === "node.updated" && event.node.kind === "tool_call") {
255
+ finalNodes.set(String(event.node.nativeItemRef?.nativeId), event.node.status);
256
+ }
257
+ }
258
+ assert.deepEqual(Object.fromEntries(finalReads), {
259
+ "Read secret.txt": { status: unfinished, output: undefined, done: true },
260
+ "Read open.txt": {
261
+ status: "completed",
262
+ output: { fileSize: 3, content: "ok\n", totalLines: 1 },
263
+ done: true,
264
+ },
265
+ });
266
+ assert.deepEqual(Object.fromEntries(finalNodes), {
267
+ "read-secret": unfinished,
268
+ "read-open": "completed",
269
+ });
270
}).pipe(
271
Effect.scoped,
272
Effect.provide(
packages/provider-cursor/src/server/adapter.ts
+2
-1
@@ -2113,7 +2113,8 @@ export const makeCursorAdapterV2 = Effect.fn("makeCursorAdapterV2")(function* (
2113
yield* emitToolArtifacts({
2114
active: tool,
2115
completed: true,
2116
- ...(input.status === "completed" ? {} : { unfinishedStatus: input.status }),
2116
+ // No completion event means the tool outcome is unknown.
2117
+ unfinishedStatus: input.status === "completed" ? "interrupted" : input.status,
2118
});
2119
}
2120
input.context.tools.clear();