fix(runtime): reconcile stale running sessions#96853
Conversation
|
Codex review: needs real behavior proof before merge. Reviewed July 7, 2026, 10:03 AM ET / 14:03 UTC. Summary PR surface: Source +529, Tests +512. Total +1041 across 13 files. Reproducibility: yes. from source: seed a persisted Review metrics: 2 noteworthy metrics.
Stored data model Merge readiness Overall follows the weaker of proof and patch quality, so missing proof can cap an otherwise strong patch. Rank-up moves:
Proof guidance:
Mantis proof suggestion Risk before merge
Maintainer options:
Next step before merge
Maintainer decision needed
Security Review detailsBest possible solution: Land a source fix that keeps reconciliation behind the session-accessor and task-status seams, preserves active and queued work, and includes current-head redacted runtime or Telegram proof for stale recovery and follow-up delivery. Do we have a high-confidence way to reproduce the issue? Yes, from source: seed a persisted Is this the best way to solve the issue? Yes, with the proof gate still open. The generic runtime recovery boundary is the right layer and the latest head routes abort cleanup through the accessor, but merge should wait for real current-head behavior proof. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against c8d95da14c5b. Label changesLabel justifications:
Evidence reviewedPR surface: Source +529, Tests +512. Total +1041 across 13 files. View PR surface stats
What I checked:
Likely related people:
What the crustacean ranks mean
Shiny media proof means a screenshot, video, or linked artifact directly shows the changed behavior. Runtime, network, CSP, and security claims still need visible diagnostics. How this review workflow works
Review history (4 earlier review cycles)
|
|
Follow-up local verification from the live incident:
This PR remains the right upstream vehicle for the Telegram forum-topic stale running-session incident. The remaining red check is the Telegram visual proof workflow, not the targeted session lifecycle regression suite. |
|
Review blocker follow-up pushed in Addressed:
Local verification:
Remaining known blocker is still the Telegram visual proof workflow, not the code review blockers above. @clawsweeper re-review |
|
🦞🧹 I asked ClawSweeper to review this item again. |
Route running-task lookups through the approved task status access seam so the reconciliation helper does not import the task registry directly.
|
Addressed the failing What changed:
Validation:
This should clear the previous |
|
Addressed the ClawSweeper P1 queued-task blocker in a follow-up commit. What changed:
Validation:
Remaining known blocker is still current-head Telegram/runtime visual proof, not this queued-task code finding. @clawsweeper re-review |
|
🦞🧹 I asked ClawSweeper to review this item again. |
|
@clawsweeper re-review |
|
🦞🧹 I asked ClawSweeper to review this item again. |
|
This pull request has been automatically marked as stale due to inactivity. |
What Problem This Solves
OpenClaw can leave a durable session row in
status="running"after the underlying embedded run/task is already gone. In Telegram forum topics, that stale row makes the next message look like it is queued behind active work even when there is no live run to wait for, leaving the topic wedged.Why This Change Was Made
The runtime already has several recovery paths for stuck sessions, restart recovery, abort handling, and delivery safety hooks, but they did not consistently reconcile persisted
runningsession rows with the real active run/task registry. This PR adds a focused reconciliation path so rows that no longer have active work are closed instead of continuing to occupy a session lane.User Impact
running.sessions.abortno-active-run cases should not leave the session permanently wedged.Evidence
AI-assisted: yes. This came from local OpenClaw incident debugging where Hermes/Codex traced topic lanes stuck behind stale running rows.
Validation from the original PR branch:
node scripts/run-vitest.mjs run src/logging/diagnostic-stuck-session-recovery.integration.test.ts src/gateway/server-methods/sessions.abort-agent-scope.test.ts src/agents/main-session-restart-recovery.test.ts src/agents/command/delivery.test.ts— passed locally before PR creationpnpm build— passed locally before PR creationRuntime evidence from the local rollout that motivated the fix:
Known gap:
Summary/Root cause/Validationheadings. This update converts it to OpenClaw's current contributor format so the real-behavior-proof gate has durable authored problem/evidence sections.