diff --git a/packages/runner/src/watchdog.ts b/packages/runner/src/watchdog.ts index 17699684..cc8e66a4 100644 --- a/packages/runner/src/watchdog.ts +++ b/packages/runner/src/watchdog.ts @@ -243,7 +243,8 @@ async function checkSession(db: Db, s: SessionView, opts: WatchdogOptions, cfg: } const label = `#${s.id} ${s.taskKey ?? ""} (${s.tmuxName})`; - if (!(await tmux.hasSession(tmux.sessionPane(s)))) { + // One failed `has-session` under load is not proof: ask again before restarting the agent. + if (!(await tmux.hasSession(tmux.sessionPane(s))) && !(await new Promise((r) => setTimeout(r, 300)).then(() => tmux.hasSession(tmux.sessionPane(s))))) { log(`${label}: tmux session gone`); await logSessionEvent(db, s, "tmux_gone"); // PEP-244: the container does not depend on tmux — without this it keeps running unattended.