mirror of
https://github.com/deepseek-ai/deepseek-harness
synced 2026-08-15 21:04:50 +00:00
The prior fix handled a throwing session/event listener on the turn/start append, but the SAME push-before-notify hazard remained on the three FINALIZER appends. Session.append pushes the event before notifying, so a throwing listener on a finalizer event left the event logged but aborted the rest of finalization — stranding the turn open. - failTurn(): set `reason` BEFORE appending the `error` event, and contain a throwing session/event listener on it (the event is already logged either way). Otherwise reason stayed unset, agent/error was skipped, and the caller's closeTurn(false) never ran → open turn. - closeStep(): the try/catch wrapped only the agent/step-end EMIT, not the step/end APPEND. A throwing session/event listener on step/end escaped — fatal when closeStep runs from the outer catch during finalization (turn/start + step/end but no turn/end). Now both the append and the emit are contained and surface as a turn error via failTurn. - closeTurn(): contain a throwing session/event listener on the turn/end append (it would propagate to the runLoop backstop from closeTurn(false), or skip the turn-end emit from closeTurn(true)). turn/end is logged either way, so the turn stays balanced. Regressions: a throwing session/event listener on the error event, on step/end during finalization (driven by a throwing agent/step-start), and on turn/end — each leaves a balanced turn and the loop survives.