From 7c970088f1f2188e31ec270e173a33dd2a22db32 Mon Sep 17 00:00:00 2001 From: Mikael Hugo Date: Sun, 10 May 2026 02:29:41 +0200 Subject: [PATCH] fix: skip missing-checkpoint repair loop when runUnit is cancelled MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit When runUnit() returns status='cancelled' (provider not ready, session failed, timeout), there is no checkpoint to repair. Previously the code called assessAutonomousSolverTurn() which saw no checkpoint and entered the 4-attempt repair loop — all of which also cancelled instantly, burning retries before pausing with a misleading solver-missing-checkpoint reason instead of surfacing the real provider/session error. Now: cancelled result short-circuits to { action: 'none' }, skipping the repair loop and falling through to the existing cancelled handler which correctly surfaces provider-not-ready, timeout, and session-failed errors. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --- src/resources/extensions/sf/auto/phases.js | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/src/resources/extensions/sf/auto/phases.js b/src/resources/extensions/sf/auto/phases.js index 1dbf1d636..3cc8f8a45 100644 --- a/src/resources/extensions/sf/auto/phases.js +++ b/src/resources/extensions/sf/auto/phases.js @@ -2247,11 +2247,12 @@ export async function runUnitPhase(ic, iterData, loopState, sidecarItem) { const unitResult = await runUnit(ctx, pi, s, unitType, unitId, finalPrompt); s.lastUnitAgentEndMessages = unitResult.event?.messages ?? null; let currentUnitResult = unitResult; - let solverAssessment = assessAutonomousSolverTurn( - s.basePath, - unitType, - unitId, - ); + // Short-circuit: if runUnit was cancelled (provider not ready, session + // failed, timeout) there is no checkpoint to repair — skip the repair loop + // entirely and let the cancelled handler below surface the real cause. + let solverAssessment = unitResult.status === "cancelled" + ? { action: "none" } + : assessAutonomousSolverTurn(s.basePath, unitType, unitId); while (solverAssessment.action === "missing-checkpoint-retry") { const diagnosis = classifyAutonomousSolverMissingCheckpointFailure( currentUnitResult.event?.messages ?? [], @@ -2296,6 +2297,10 @@ export async function runUnitPhase(ic, iterData, loopState, sidecarItem) { ), ); s.lastUnitAgentEndMessages = currentUnitResult.event?.messages ?? null; + if (currentUnitResult.status === "cancelled") { + solverAssessment = { action: "none" }; + break; + } solverAssessment = assessAutonomousSolverTurn(s.basePath, unitType, unitId); } const solverCheckpoint = solverAssessment.checkpoint;