Neverdie
Automatically revives DeepSeek Harness (DSH) sessions whose turn was killed by a process exit. When the host dies mid-turn, every session that was working ends up frozen behind a "Task stopped — The DSH process exited before this turn finished…" banner, dead until a human types something. Neverdie removes the human from that loop: after DSH restarts, the killed sessions come back to life on their own and keep working — and their active goals get re-armed so autonomous goal rounds continue.
Why
A DSH process that is killed, crashes, or times out during shutdown takes every running session down with it. Restart recovery closes the open turn with reason interrupted and the session sits idle with the "Task stopped" failure — even though the durable session log, the workspace, and the model context are all intact. All the work was interrupted, not lost. Long-running jobs (overnight builds, multi-hour agent tasks, goal-driven rounds) deserved better than "click Send again in the morning".
Neverdie is a host-side Cordis plugin that scans once after every boot, finds exactly the sessions that were mid-turn when the previous process died, and re-prompts them with a short configurable message so the agent resumes where it stopped.
Features
- Precise corpse detection — a session is revived only when the tail of its balanced log is a
turn/endclosedinterrupted. Sessions that ended normally, or that already have newer input, are never touched - Survives restart bookkeeping — the tail walker skips generation markers (e.g.
session/end-seed) that DSH appends after a restart, and synthesizes the interrupted closers in memory for cold logs, so detection works whether or not the session was reopened first - Live-but-idle counts as dead — the reconnecting web client resumes a session's log without resuming its work; neverdie treats that idle state as a corpse too
- Goal re-arm — goal activation is process-local, so the restart that killed the turn also disarmed the session's goal. Neverdie re-arms active goals through the supported
goals.resumepath, so automatic continuation rounds keep running. Paused, blocked, complete, or round-exhausted goals are respected as-is - Crash-loop guard — at most
maxRevivesconsecutive neverdie revives per session since the last genuine user message; a host that keeps dying cannot burn tokens forever, and one real user message resets the budget - Auditable — every revive is a normal user message tagged with the merge-extensible source kind
neverdie, visible in the transcript and countable from the session log, plus a[neverdie]line in the host journal
How it works
- The host process dies mid-turn. The plugin dies with it — nothing can act at the moment of death.
- Whatever supervises DSH (e.g. systemd
Restart=on-failure) starts a new process; the plugin arms and waitsdelaySecondsfor boot to settle. - One scan: list sessions cheaply, then fully read the balanced log of each fresh, non-archived, root candidate.
- A backward walker finds the log's last turn end; only an
interruptedone with no newer turn, message, or pending inbox input qualifies. - For each corpse:
resolveAgent(resumes the cold session), re-arm its active goal if disarmed, queue the revive message, flush to durable storage. - The agent continues the interrupted task. If the host dies again, the next boot repeats the cycle within the revive budget.
Configuration
| Option | Type | Default | Description |
|---|---|---|---|
enabled |
boolean |
true |
Master switch |
delaySeconds |
number |
10 |
Wait after host start before the startup scan (0–600) |
maxAgeMinutes |
number |
60 |
Only revive sessions whose interrupted turn is younger than this (1–1440) |
maxRevives |
number |
5 |
Max consecutive neverdie revives per session without genuine user input (0–10) |
reviveMessage |
string |
(see below) | The message injected to revive a session |
resumeGoals |
boolean |
true |
Re-arm active-but-disarmed goals during revival |
Default revive message:
[neverdie] The DSH process exited before the previous turn could finish, so that turn was closed. Continue the interrupted task from where it stopped. Tool calls that were cut off have unknown outcomes — inspect their effects before retrying them.
Notes & limitations
- Restart must come from outside. Neverdie revives sessions after the host is back; it cannot restart the host itself. Pair it with a supervisor such as systemd (
Restart=on-failure). - A literal empty prompt is not possible. The harness rejects whitespace-only prompt content, so revival sends a real (short, configurable) message instead.
- Root conversations only. Subagent children are left to their parent sessions, which the parent's own revival reconciles.
- Freshness bounded. Corpses older than
maxAgeMinutesstay dead — raise the window if your host can be down for a long time.
License
MIT © pinion05
No comments yet. Be the first to write one.