From 4442400d11f352e851a5642e677ca8546e998d80 Mon Sep 17 00:00:00 2001 From: Mikael Hugo Date: Sat, 16 May 2026 15:29:43 +0200 Subject: [PATCH] sf snapshot: uncommitted changes after 30m inactivity --- src/resources/extensions/sf/auto/run-unit.js | 43 ++++++++++++++++++-- 1 file changed, 39 insertions(+), 4 deletions(-) diff --git a/src/resources/extensions/sf/auto/run-unit.js b/src/resources/extensions/sf/auto/run-unit.js index 3a2963f48..8f247cd2d 100644 --- a/src/resources/extensions/sf/auto/run-unit.js +++ b/src/resources/extensions/sf/auto/run-unit.js @@ -1344,10 +1344,45 @@ export async function runUnit(ctx, pi, s, unitType, unitId, prompt, options) { prompt, promptCacheSplit, ); - await pi.sendMessage( - { customType: "sf-auto", content: messageContent, display: s.verbose }, - { triggerTurn: true }, - ); + // #sf-mp8d3hfc-0rccrj: pi.sendMessage was previously awaited bare. If it + // threw, the error propagated but with no contextual marker about which + // stage failed (model selection / RPC bridge / agent receive). If it + // resolved but the RPC child never processed the message, the unit froze + // at iteration 1 with no user message in the session JSONL and no + // diagnostic trail. Wrap both sides for visibility. + const sendStartedAt = Date.now(); + debugLog("runUnit", { + phase: "send-message-start", + unitType, + unitId, + messageContentLength: + typeof messageContent === "string" + ? messageContent.length + : JSON.stringify(messageContent).length, + }); + try { + await pi.sendMessage( + { customType: "sf-auto", content: messageContent, display: s.verbose }, + { triggerTurn: true }, + ); + } catch (e) { + debugLog("runUnit", { + phase: "send-message-failed", + unitType, + unitId, + error: e && typeof e === "object" && "message" in e ? e.message : String(e), + stack: + e && typeof e === "object" && "stack" in e ? String(e.stack) : undefined, + elapsedMs: Date.now() - sendStartedAt, + }); + throw e; + } + debugLog("runUnit", { + phase: "send-message-accepted", + unitType, + unitId, + elapsedMs: Date.now() - sendStartedAt, + }); } finally { if (savedTools) { pi.setActiveTools(savedTools);