From 7177ae1264999bab6025d8da56fef1c8630ee442 Mon Sep 17 00:00:00 2001 From: Julius Marminge Date: Fri, 3 Jul 2026 02:46:06 -0700 Subject: [PATCH] Persist cursor run correlation data on turn failures MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 --- .../orchestration-v2/Adapters/CursorAdapterV2.ts | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/apps/server/src/orchestration-v2/Adapters/CursorAdapterV2.ts b/apps/server/src/orchestration-v2/Adapters/CursorAdapterV2.ts index bda1e0d909..ae5ae17764 100644 --- a/apps/server/src/orchestration-v2/Adapters/CursorAdapterV2.ts +++ b/apps/server/src/orchestration-v2/Adapters/CursorAdapterV2.ts @@ -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", }),