openclaw - 💡(How to fix) Fix [Bug]: Gateway restart resurrects ancient interrupted CLI subagent tasks regardless of age — old prompts auto-execute [2 comments, 3 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#69778Fetched 2026-04-22 07:48:23
View on GitHub
Comments
2
Participants
3
Timeline
2
Reactions
0
Timeline (top)
commented ×2

After a gateway restart, the runtime restored 13 cli subagent tasks that had been interrupted ~24h earlier and re-executed 9 of them (succeeded), 2 cancelled, 1 failed. The original prompts were re-run automatically, prefixed with the standard:

[System] Your previous turn was interrupted by a gateway reload. Your original task was: ...

There is no age bound on recovery — interrupted tasks from days/weeks ago are flipped back to running and dispatched to a fresh subagent the moment the gateway comes back up. From the user's perspective, "OpenClaw spontaneously started processing problems from a long time ago."

Root Cause

After a gateway restart, the runtime restored 13 cli subagent tasks that had been interrupted ~24h earlier and re-executed 9 of them (succeeded), 2 cancelled, 1 failed. The original prompts were re-run automatically, prefixed with the standard:

[System] Your previous turn was interrupted by a gateway reload. Your original task was: ...

There is no age bound on recovery — interrupted tasks from days/weeks ago are flipped back to running and dispatched to a fresh subagent the moment the gateway comes back up. From the user's perspective, "OpenClaw spontaneously started processing problems from a long time ago."

Fix Action

Workaround

Manual cancel + openclaw tasks maintenance --apply after every restart. Documented community-side as the openclaw-zombie-tasks recipe; would prefer this be unnecessary.

RAW_BUFFERClick to expand / collapse

Bug type

Behavior bug (incorrect output/state without crash)

Version

OpenClaw 2026.4.15 (041266a), macOS

Summary

After a gateway restart, the runtime restored 13 cli subagent tasks that had been interrupted ~24h earlier and re-executed 9 of them (succeeded), 2 cancelled, 1 failed. The original prompts were re-run automatically, prefixed with the standard:

[System] Your previous turn was interrupted by a gateway reload. Your original task was: ...

There is no age bound on recovery — interrupted tasks from days/weeks ago are flipped back to running and dispatched to a fresh subagent the moment the gateway comes back up. From the user's perspective, "OpenClaw spontaneously started processing problems from a long time ago."

Reproduction

  1. Spawn one or more cli subagent tasks (e.g. via delegate_task).
  2. Hard-kill / restart the gateway while they are running.
  3. Wait an arbitrary amount of time (hours, days).
  4. Start the gateway again.
  5. Observe: the previously interrupted tasks are restored to running and their prompts re-execute autonomously.

Observed

  • openclaw tasks list shows ~13 entries with createdAt 24h+ old, all with the "interrupted by a gateway reload" prefix in their prompt.
  • 9/13 ran to completion (succeeded), 2 cancelled mid-flight, 1 failed.
  • ownerKey pattern: agent:*:subagent:*, runtime: cli.
  • Cancelling a running zombie can trigger one auto-revival ~15s later before staying dead.

Expected

Gateway recovery should bound resurrection by task age. Interrupted tasks older than some threshold (e.g. > 1–2 hours, or configurable via agents.defaults.taskRecovery.maxAgeMinutes) should be marked lost instead of being re-dispatched. Optionally a startup notice listing how many stale tasks were skipped.

Impact

  • Side effects (file writes, API calls, paper edits, code generation) fire long after the user has moved on, against a now-stale workspace state.
  • For long-lived setups (Mac mini under desk, per the README), the zombie pool grows unboundedly between restarts.
  • Confusing UX — looks like the agent went rogue.

Workaround

Manual cancel + openclaw tasks maintenance --apply after every restart. Documented community-side as the openclaw-zombie-tasks recipe; would prefer this be unnecessary.

Suggested fix

  1. Add agents.defaults.taskRecovery.maxAgeMinutes (default ~120).
  2. On gateway start, mark interrupted/lost tasks older than the threshold as lost and skip dispatch.
  3. Surface a one-line startup log: "Skipped N stale tasks older than Xm during recovery."
  4. (Nice to have) openclaw tasks list --status lost filter parity.

Related: #66909 (doc clarification on whether tasks should resume). This is the concrete bug + proposed bound.

extent analysis

TL;DR

Implement a task age threshold to prevent old tasks from being re-executed after a gateway restart.

Guidance

  • Introduce a configurable agents.defaults.taskRecovery.maxAgeMinutes parameter to set the maximum age for task recovery.
  • On gateway startup, filter out interrupted tasks older than the specified threshold and mark them as lost instead of re-dispatching them.
  • Consider adding a startup log message to indicate the number of stale tasks skipped during recovery.
  • To verify the fix, test the gateway restart scenario with tasks of varying ages and check that only tasks within the threshold are re-executed.

Example

No code snippet is provided as the issue does not contain specific code references.

Notes

The proposed fix relies on introducing a new configuration parameter and modifying the task recovery logic. This may require additional testing to ensure correct behavior under different scenarios.

Recommendation

Apply the suggested fix by introducing the agents.defaults.taskRecovery.maxAgeMinutes parameter and implementing the corresponding task filtering logic, as this addresses the root cause of the issue and provides a configurable solution.

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

openclaw - 💡(How to fix) Fix [Bug]: Gateway restart resurrects ancient interrupted CLI subagent tasks regardless of age — old prompts auto-execute [2 comments, 3 participants]