Skip to content

[Bug]: orphan recovery can resurrect stale subagent runs after long downtime #90766

Description

@Timofa

Bug type

Behavior bug (incorrect output/state without crash)

Beta release blocker

No

Summary

After restart, orphan recovery can treat very old subagent runs as resumable work instead of aging them out and marking them stale.

Steps to reproduce

  1. Start a subagent run that writes normal recovery metadata.
  2. Leave it unresolved across downtime that is longer than the recovery staleness window.
  3. Restart the gateway.
  4. Observe that the old subagent run is reconsidered for replay/resume instead of being classified as stale and retired.

Expected behavior

Old orphaned subagent runs should age out after the recovery staleness window and be marked stale or failed instead of being resumed automatically.

Actual behavior

The orphan-recovery path can still classify stale runs as active/recoverable and attempt replay/resume after restart.

OpenClaw version

2026.4.8

Operating system

Linux 6.8.0-107-generic

Install method

pnpm global

Model

openai-codex/gpt-5.4 (issue is subagent lifecycle dependent, not model-specific)

Provider / routing chain

openclaw -> OpenAI (provider path not required for reproduction)

Additional provider/model setup details

Observed in a self-hosted Linux gateway while auditing subagent restart recovery. The issue is in subagent lifecycle recovery rather than model/provider behavior.

Logs, screenshots, and evidence

Observed behavior:
- a stale orphaned subagent session remained eligible for restart recovery
- the local runtime needed an explicit staleness guard so old orphaned runs would be skipped rather than auto-resurrected

Relevant runtime indicators from the local fix:
- recovery max-age handling for orphaned runs
- stale-orphan reconciliation before replay/resume
- stale-skip accounting in orphan-recovery results

Impact and severity

Affected: deployments that use subagents and experience restarts or downtime during child-task execution
Severity: High (can replay stale work and produce misleading late completions)
Frequency: Observed when an orphaned child survives past the staleness window and recovery runs after restart
Consequence: users can receive duplicate or contextless child-task work long after the original run should have been retired

Additional information

This looks adjacent to, but distinct from, #90444 / #90505. Those cover killed subagent task-row finalization. This report is about restart-time orphan recovery misclassifying stale child runs as resumable.

Metadata

Metadata

Assignees

No one assigned

    Labels

    P2Normal backlog priority with limited blast radius.clawsweeper:linked-pr-openClawSweeper found an open linked pull request for this issue.clawsweeper:no-new-fix-prClawSweeper does not recommend queueing a new automated fix PR for this issue.clawsweeper:source-reproClawSweeper found a high-confidence source-level issue reproduction.impact:session-stateSession, memory, transcript, context, or agent state can drift or corrupt.issue-rating: 🦞 diamond lobsterVery strong issue quality with high-confidence source-level or clear reproduction.

    Type

    No type

    Fields

    Priority

    None yet

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions