Skip to content

Commit da37bd4

Browse files
committed
fix(server): add Cursor's reason at the adapter, not in the runner error's message
1 parent c97584f commit da37bd4

3 files changed

Lines changed: 21 additions & 7 deletions

File tree

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

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -302,9 +302,18 @@ describe("CursorAgentSdkRunner", () => {
302302
}).pipe(Effect.provide(layerTest)),
303303
);
304304

305-
it("names the SDK's reason, code and HTTP status in a runner error", () => {
305+
it("names the SDK's reason, code and HTTP status in a runner failure's text", () => {
306306
const failed = (cause: unknown) =>
307-
new CursorAgentSdk.CursorAgentSdkRunnerError({ method: "agent.create", cause }).message;
307+
CursorAgentSdk.cursorSdkFailureMessage(
308+
new CursorAgentSdk.CursorAgentSdkRunnerError({ method: "agent.create", cause }),
309+
);
310+
assert.equal(
311+
new CursorAgentSdk.CursorAgentSdkRunnerError({
312+
method: "agent.create",
313+
cause: new Error("Too many requests"),
314+
}).message,
315+
"Cursor Agent SDK agent.create failed.",
316+
);
308317
assert.equal(
309318
failed(Object.assign(new Error("Too many requests"), { code: "rate_limited", status: 429 })),
310319
"Cursor Agent SDK agent.create failed: Too many requests (rate_limited, HTTP 429)",

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

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,13 +30,18 @@ export class CursorAgentSdkRunnerError extends Schema.TaggedError<CursorAgentSdk
3030
},
3131
) {
3232
override get message(): string {
33-
const reason = sdkErrorReason(this.cause);
34-
return reason === undefined
35-
? `Cursor Agent SDK ${this.method} failed.`
36-
: `Cursor Agent SDK ${this.method} failed: ${reason}`;
33+
return `Cursor Agent SDK ${this.method} failed.`;
3734
}
3835
}
3936

37+
/** The failure text a user sees: the SDK's own reason, which the error's message leaves out. */
38+
export function cursorSdkFailureMessage(error: CursorAgentSdkRunnerError): string {
39+
const reason = sdkErrorReason(error.cause);
40+
return reason === undefined
41+
? error.message
42+
: `Cursor Agent SDK ${error.method} failed: ${reason}`;
43+
}
44+
4045
/** Codes Cursor sends when it has no specific one. */
4146
const GENERIC_SDK_ERROR_CODES = new Set(["", "error", "unknown"]);
4247

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2324,7 +2324,7 @@ export function makeCursorAdapterV2(
23242324
failure: makeProviderFailure({
23252325
cause,
23262326
message: CursorAgentSdk.isCursorAgentSdkRunnerError(cause)
2327-
? cause.message
2327+
? CursorAgentSdk.cursorSdkFailureMessage(cause)
23282328
: undefined,
23292329
class: "transport_error",
23302330
}),

0 commit comments

Comments
 (0)