Skip to content

Bug: Subagent child sessions receive no termination signal when parent dies mid-run #77720

Description

@slideshow-dingo

Summary

When a subagent session dies mid-run (OOM kill, SIGUSR1 restart, or abrupt failed exit), its active child sub-subagent sessions receive no termination signal. Children sit in `stale_running` indefinitely — the gateway marks them "running" but no agent polls them and they never complete. Only manual cancellation or `openclaw maintenance --apply` cleans them up.

Steps to Reproduce

  1. Spawn a depth-1 subagent via `sessions_spawn`
  2. From the depth-1 session, spawn a depth-2 sub-subagent via `sessions_spawn`
  3. Kill the depth-1 parent session abruptly (e.g., `SIGUSR1` to gateway, OOM kill, or `openclaw sessions kill`)
  4. Observe: the depth-2 child remains in `stale_running` forever

Expected Behavior

When a parent session dies, all its descendant sessions should either:

  • Receive a termination signal and clean up gracefully, OR
  • Be listed as orphaned and eligible for automatic cleanup

Actual Behavior

Depth-2 children become orphaned with no lineage connection to a living agent. Gateway shows them as `running` but they are never polled again. `openclaw tasks audit` reports `stale_running` indefinitely.

Version

```
OpenClaw 2026.5.3-1 (2eae30e)
```

OS: Linux 6.8.0-110-generic (x64)

Evidence

Live task IDs from a production instance (anonymized session keys):

Task ID Parent Session Label Trigger
`109245ed-0305-452c-b953-86507b39e568` `agent:main:subagent:79b6b6a8` gap-analysis Gateway restart
`6737bbde-f126-45cf-a060-eac36f53d87c` `agent:main:subagent:c2d1dcfc` gap-analysis Gateway restart
`ddb62685-f353-4ca1-a250-e70682b2df77` `agent:main:subagent:44af2dfa` se-gap-analysis Parent failed
`899ca059-14f5-4ddb-b185-0377b99cc96a` `agent:main:subagent:04ed3568` sre-gap-analysis Parent failed
`62f3c65e-ee01-4b9a-8c7d-15cc4045398d` `agent:main:subagent:a0e1bd52` rca-fnm-gateway-path Parent failed
`fffe6df3-b729-4801-b805-036160dcf92b` `agent:main:subagent:5f3a750f` rca-sessions-transcripts Parent failed

`openclaw tasks audit` output:

Task  error  stale_running  109245ed-...  running  1d17h
Task  error  stale_running  6737bbde-...  running  1d17h
[...4 more...]

Impact

  • Orphaned tasks accumulate in gateway task registry
  • `stale_running` errors trigger automated alerting noise
  • Manual cleanup required to recover
  • Makes depth-2 subagent spawning unsafe in production

Severity

High — reliability/usability of multi-agent orchestration.

Proposed Fix (direction, not prescriptive)

Option A: Gateway tracks parent→child registry; on parent death, iterate children and send termination signal or mark them `orphaned`.

Option B: Subagent children monitor parent session heartbeat; if parent goes dark for N consecutive heartbeats, child self-terminates with a defined exit state.

Either approach closes the lifecycle management gap without changing the spawn permission model.

Related Issues

See also:

Metadata

Metadata

Assignees

No one assigned

    Labels

    P1High-priority user-facing bug, regression, or broken workflow.clawsweeper:needs-live-reproClawSweeper needs live local, crabbox, or manual validation to confirm this issue.clawsweeper:needs-maintainer-reviewClawSweeper marked this issue as needing maintainer review before automation.clawsweeper:needs-product-decisionClawSweeper marked this issue as needing a product or behavior decision.clawsweeper:no-new-fix-prClawSweeper does not recommend queueing a new automated fix PR for this issue.impact:session-stateSession, memory, transcript, context, or agent state can drift or corrupt.issue-rating: 🐚 platinum hermitGood issue quality with a plausible reproduction path needing some confirmation.maturity:stableIssue affects a taxonomy feature currently scored M4/M5.staleMarked as stale due to inactivity

    Type

    No type

    Fields

    Priority

    None yet

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions