fix: skip missing-checkpoint repair loop when runUnit is cancelled

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>
This commit is contained in:
Mikael Hugo 2026-05-10 02:29:41 +02:00
parent d6bd49d0b6
commit 7c970088f1

View file

@ -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;