fix(gate): auto-finalize session after last phase approval
The model sometimes stops after receiving 'Fase approvata' without calling `tht session finalize`, leaving the session open. Now the gate itself calls finalize after advancing the max phase (F8), making session closure deterministic regardless of model behavior. - reviewer_confirm kind:phase: after phase advance at max_phase, gate calls `tht session finalize <session>` (best-effort with recovery message) - SKILL.md updated: model no longer needs to call finalize itself - Tests: 2 new JS tests (auto-finalize at max phase; no-finalize at non-max) Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -957,6 +957,23 @@ export default function (pi) {
|
||||
PHASE_RECOVERY,
|
||||
);
|
||||
if (err) return err;
|
||||
// Auto-finalize after advancing the LAST phase: the model may not
|
||||
// follow through (token budget, turn end) leaving the session open.
|
||||
const meta = phaseMeta(ctx);
|
||||
if (curNum >= meta.max_phase) {
|
||||
const fErr = relayIfThtFails(
|
||||
ctx,
|
||||
["session", "finalize", session],
|
||||
"Fase approvata ma finalizzazione fallita: esegui manualmente " +
|
||||
`\`tht session finalize ${session}\`.`,
|
||||
);
|
||||
if (fErr) return fErr;
|
||||
lockActive = false;
|
||||
lastSteered = false;
|
||||
return textResult(
|
||||
`Fase ${curNum} approvata e sessione finalizzata (${session}).`,
|
||||
);
|
||||
}
|
||||
return textResult(`Fase approvata (sessione ${session}).`);
|
||||
}
|
||||
if (kind === "cte_plan") {
|
||||
|
||||
Reference in New Issue
Block a user