Skip to content

Commit 4f07a45

Browse files
saphidclaude
authored andcommitted
fix(cursor): shell commands that exit non-zero are recorded as failed
Co-Authored-By: Claude Opus 5.5 <[email protected]>
1 parent d8a829e commit 4f07a45

2 files changed

Lines changed: 24 additions & 0 deletions

File tree

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

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,25 @@ describe("CursorAdapterV2", () => {
141141
: {}),
142142
},
143143
})),
144+
{
145+
type: "tool-call-completed",
146+
modelCallId: "native-model-call",
147+
callId: "shell-exit-1",
148+
toolCall: {
149+
type: "shell",
150+
args: { command: "vp test" },
151+
result: {
152+
status: "success",
153+
value: {
154+
exitCode: 1,
155+
signal: "",
156+
stdout: "",
157+
stderr: "1 failed",
158+
executionTime: 1,
159+
},
160+
},
161+
},
162+
},
144163
];
145164
for (const update of readUpdates) {
146165
yield* input.onDelta!(update).pipe(Effect.orDie);
@@ -268,6 +287,7 @@ describe("CursorAdapterV2", () => {
268287
assert.deepEqual(Object.fromEntries(finalNodes), {
269288
"read-secret": unfinished,
270289
"read-open": "completed",
290+
"shell-exit-1": "failed",
271291
});
272292
}).pipe(
273293
Effect.scoped,

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -367,6 +367,10 @@ function cursorToolFailed(toolCall: ToolCall): boolean {
367367
if (toolCall.result?.status === "error") {
368368
return true;
369369
}
370+
// The SDK reports a shell command that exits non-zero as a success.
371+
if (toolCall.type === "shell" && toolCall.result?.status === "success") {
372+
return toolCall.result.value.exitCode !== 0;
373+
}
370374
return toolCall.type === "mcp" && toolCall.result?.status === "success"
371375
? toolCall.result.value.isError
372376
: false;

0 commit comments

Comments
 (0)