Skip to content

Commit f7c2fee

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

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
@@ -305,9 +305,18 @@ describe("CursorAgentSdkRunner", () => {
305305
}).pipe(Effect.provide(layerTest)),
306306
);
307307

308-
it("names the SDK's reason, code and HTTP status in a runner error", () => {
308+
it("names the SDK's reason, code and HTTP status in a runner failure's text", () => {
309309
const failed = (cause: unknown) =>
310-
new CursorAgentSdk.CursorAgentSdkRunnerError({ method: "agent.create", cause }).message;
310+
CursorAgentSdk.cursorSdkFailureMessage(
311+
new CursorAgentSdk.CursorAgentSdkRunnerError({ method: "agent.create", cause }),
312+
);
313+
assert.equal(
314+
new CursorAgentSdk.CursorAgentSdkRunnerError({
315+
method: "agent.create",
316+
cause: new Error("Too many requests"),
317+
}).message,
318+
"Cursor Agent SDK agent.create failed.",
319+
);
311320
assert.equal(
312321
failed(Object.assign(new Error("Too many requests"), { code: "rate_limited", status: 429 })),
313322
"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
@@ -32,13 +32,18 @@ export class CursorAgentSdkRunnerError extends Schema.TaggedError<CursorAgentSdk
3232
},
3333
) {
3434
override get message(): string {
35-
const reason = sdkErrorReason(this.cause);
36-
return reason === undefined
37-
? `Cursor Agent SDK ${this.method} failed.`
38-
: `Cursor Agent SDK ${this.method} failed: ${reason}`;
35+
return `Cursor Agent SDK ${this.method} failed.`;
3936
}
4037
}
4138

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

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2329,7 +2329,7 @@ export const makeCursorAdapterV2 = Effect.fn("makeCursorAdapterV2")(function* (
23292329
failure: makeProviderFailure({
23302330
cause,
23312331
message: CursorAgentSdk.isCursorAgentSdkRunnerError(cause)
2332-
? cause.message
2332+
? CursorAgentSdk.cursorSdkFailureMessage(cause)
23332333
: undefined,
23342334
class: "transport_error",
23352335
}),

0 commit comments

Comments
 (0)