openclaw - ✅(Solved) Fix Task state not reconciled on gateway restart — stale running tasks accumulate [1 pull requests, 1 participants]

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…
GitHub stats
openclaw/openclaw#65136Fetched 2026-04-12 13:25:23
View on GitHub
Comments
0
Participants
1
Timeline
1
Reactions
0
Author
Participants
Timeline (top)
cross-referenced ×1

Fix Action

Fixed

PR fix notes

PR #65155: fix: reconcile stale subagent tasks after reset

Description (problem / solution / changelog)

Summary

  • treat subagent, ACP, and CLI task records as live only while their run context is still registered
  • stop relying on persisted session rows alone, which survive /reset and gateway restart
  • add regressions covering reset-stale subagent tasks and keep existing stale-running audit coverage explicit

Testing

  • pnpm test src/tasks/task-registry.maintenance.issue-60299.test.ts src/tasks/task-registry.test.ts

Issue

  • closes #65136

Changed files

  • src/tasks/task-registry.maintenance.issue-60299.test.ts (modified, +54/-1)
  • src/tasks/task-registry.maintenance.ts (modified, +7/-3)
  • src/tasks/task-registry.test.ts (modified, +1/-0)
RAW_BUFFERClick to expand / collapse

Problem

When a gateway restart or /reset kills running sub-agent processes, their task records remain in status=running indefinitely. Over time these stale records accumulate, inflating the running count and polluting audit results.

Reproduction

  1. Spawn sub-agents (e.g. via sessions_spawn)
  2. While sub-agents are running, restart gateway or /reset the session
  3. Run openclaw tasks audit — stale_running and lost tasks appear
  4. Run openclaw tasks maintenance --apply — 0 tasks reconciled (no-op)

Current Behavior

  • openclaw tasks audit correctly detects stale_running tasks and lost task_runs
  • openclaw tasks maintenance does NOT auto-reconcile them (reports "0 reconcile")
  • No crash recovery happens on gateway startup — stale records persist until manual DB surgery

Expected Behavior

On gateway startup, automatically reconcile all status=running tasks whose sub-agent processes no longer exist → mark as lost or timed_out. This is basic crash recovery for any task orchestration system.

Alternatively, openclaw tasks maintenance --apply should handle these cases.

Environment

  • OpenClaw 2026.4.9 (0512059)
  • Node v22.22.0
  • Linux 5.15.0-113-generic (x64)

extent analysis

TL;DR

Modify the openclaw tasks maintenance command to automatically reconcile stale task records by marking them as lost or timed_out when the corresponding sub-agent processes no longer exist.

Guidance

  • Investigate the openclaw tasks maintenance command to determine why it does not auto-reconcile stale task records, despite correctly detecting them.
  • Consider adding a crash recovery mechanism to the gateway startup process to reconcile stale task records.
  • Review the database schema to understand how task records are stored and updated, which may help identify the root cause of the issue.
  • Test the openclaw tasks maintenance --apply command with different scenarios to see if it can be forced to reconcile stale task records.

Example

No code example is provided as the issue does not contain sufficient information about the implementation details.

Notes

The provided information suggests that the issue is related to the task reconciliation mechanism in OpenClaw, but more details about the implementation and database schema are needed to provide a definitive solution.

Recommendation

Apply a workaround by modifying the openclaw tasks maintenance command to handle stale task records, as upgrading to a fixed version is not mentioned in the issue. This is because the issue seems to be related to the implementation of the task reconciliation mechanism, which can be addressed by modifying the existing code.

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING