openhuman icon indicating copy to clipboard operation
openhuman copied to clipboard

Agent runs left in flight by a core restart stay in the active listing forever

Open yh928 opened this issue 4 months ago • 0 comments

Summary

Every agent run still in a non-terminal state when the core process exits stays in openhuman.agent_runs_active forever. A long-lived instance was observed carrying 50 such zombie runs.

Problem

The core is a single in-process runtime, so a crash, restart, or deploy takes every in-flight run with it. The durable status store keeps whatever state those runs were last persisted in — Pending, Running, or Interrupted — but the task that owned each one is gone: no executor remains to advance it, and no cancel path can reach it. Nothing reconciles the store against that on the way back up.

What you see:

  1. Start a turn (or several) so runs are in flight.
  2. Restart the core, or let it crash mid-turn.
  3. Read openhuman.agent_runs_active.

Expected: the listing is empty, or shows only runs a live task is actually driving. Actual: every run from the previous process is still listed as active, and stays listed for the life of the workspace.

The listing is what the UI and the orchestration surfaces read to answer "what is running", so the count is wrong for every consumer, and it only grows.

Solution (optional)

Sweep the persistent status store once at boot, before readiness is published, moving each still-active run to a terminal state with a stable reason. Cancelled rather than Failed — a restart is not a run failure, and Failed renders every reaped run as a red error row.

Acceptance criteria

  • [ ] Repro gone — after a restart, agent_runs_active reflects only runs a live task is driving.
  • [ ] Boot is never blocked — a store that cannot be opened or listed logs and yields zero rather than failing startup.
  • [ ] Idempotent — a second sweep over an already-swept store is a no-op.
  • [ ] Regression safety — unit coverage for the sweep and for the boot wiring.
  • [ ] Diff coverage ≥ 80% — the fix PR meets the changed-lines coverage gate.

Related

Fix: #5261

yh928 avatar Jul 31 '26 08:07 yh928