Skip to content
Source
Sign inSign up
pingdotgg/t3code

fix(server): failed Cursor turns show Cursor's reason #16146

Mergednkoynov(GitHub profile, opens in a new tab)merged 2 commits intomain fromrefs/pull/16146/headmerged by juliusmarminge View on GitHub

Showing 4 changed files with 199 additions and 1 deletion (loading 1).

x
0 of 4 viewed, 4 left
30 additions and 0 deletionspackages/provider-cursor/src/server/CursorAgentSdk.test.tsModified
View file
@@ -304,4 +304,34 @@
assert.equal(cursorSdkMock.runWait.mock.calls.length, 1);
}).pipe(Effect.provide(layerTest)),
+​
+ it("names the SDK's reason, code and HTTP status in a runner failure's text", () => {
+ const failed = (cause: unknown) =>
+ CursorAgentSdk.cursorSdkFailureMessage(
+ new CursorAgentSdk.CursorAgentSdkRunnerError({ method: "agent.create", cause }),
+ );
+ assert.equal(
+ new CursorAgentSdk.CursorAgentSdkRunnerError({
+ method: "agent.create",
+ cause: new Error("Too many requests"),
+ }).message,
+ "Cursor Agent SDK agent.create failed.",
+ );
+ assert.equal(
+ failed(Object.assign(new Error("Too many requests"), { code: "rate_limited", status: 429 })),
+ "Cursor Agent SDK agent.create failed: Too many requests (rate_limited, HTTP 429)",
+ );
+ // Cursor's messages often start with the code already.
+ assert.equal(
+ failed(
+ Object.assign(new Error("[resource_exhausted] Error"), { code: "resource_exhausted" }),
+ ),
+ "Cursor Agent SDK agent.create failed: [resource_exhausted] Error",
+ );
+ assert.equal(
+ failed(Object.assign(new Error("Invalid User API Key"), { code: "error", status: 401 })),