fix: return "dispatched" after doctor heal to prevent session race (#1580) (#1610)

After dispatchDoctorHeal fires pi.sendMessage({ triggerTurn: true }),
the function fell through to return "continue". The auto-loop treated
"continue" as "proceed to next unit", called newSession() while the
session manager was still processing the heal turn, and the 30s timeout
killed auto-mode.

Returning "dispatched" causes the auto-loop to break, letting the heal
turn complete and trigger its own handleAgentEnd to resume the loop.

Closes #1580

Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
TÂCHES 2026-03-20 10:27:34 -06:00 committed by GitHub
parent 43d8dbc9d3
commit fc4cb836fe

View file

@ -194,6 +194,7 @@ export async function postUnitPreVerification(pctx: PostUnitContext, opts?: PreV
const reportText = formatDoctorReport(report, { scope: doctorScope, includeWarnings: true });
const structuredIssues = formatDoctorIssuesForPrompt(actionable);
dispatchDoctorHeal(pi, doctorScope, reportText, structuredIssues);
return "dispatched";
} catch (e) {
debugLog("postUnit", { phase: "doctor-heal-dispatch", error: String(e) });
}