Persist cursor run correlation data on turn failures

A failed cursor turn projected only the generic "Provider turn failed."
because the adapter read a nonexistent `error` field off RunResult
(@cursor/sdk 1.0.22 carries no error text on results; errorCode lives
only in the SDK's internal run store). Persist what the result does
carry — run id, requestId, and duration — so failures can be matched to
Cursor-side logs (audit plan #3, thread c9e72a05 run 2 lost requestId
beca30c7 + 440s duration). The speculative `error` read stays as a
makeProviderFailure cause for future SDK versions.

Co-Authored-By: Claude Fable 5 <[email protected]>
This commit is contained in:
Julius MarmingeandClaude Fable 5 committed 2026-07-12 11:51:17 +02:00
1 parent 20a1f53ae2
commit 7177ae1264
1 file changed
+15
@@ -2162,7 +2162,22 @@ export function makeCursorAdapterV2(
status,
...(status === "failed"
? {
// RunResult carries no error text in @cursor/sdk
// 1.0.22 (errorCode lives only in the SDK's
// internal run store); persist the correlation
// data we do get so the failure can be matched to
// Cursor-side logs. `error` is read speculatively
// for future SDK versions.
failure: makeProviderFailure({
message: [
`Cursor run ${result.id} ended with status "error".`,
...(result.requestId === undefined
? []
: [`requestId ${result.requestId}`]),
...(result.durationMs === undefined
? []
: [`after ${Math.round(result.durationMs / 1000)}s`]),
].join(" "),
cause: (result as { readonly error?: unknown }).error,
class: "provider_error",
}),