openclaw - 💡(How to fix) Fix Bug: native subagent completion output not delivered to parent agent (delivery_status stuck on 'pending') [1 comments, 2 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#78656Fetched 2026-05-07 03:34:16
View on GitHub
Comments
1
Participants
2
Timeline
5
Reactions
2
Timeline (top)
mentioned ×2subscribed ×2commented ×1

Root Cause

Two separate failure points in the completion/capture/delivery pipeline:

Fix Action

Fix / Workaround

Files Modified (dist patches — for reference only)

These are compiled/bundled dist files and not meant to be edited directly. The patches below are provided as reference implementations — they demonstrate the fix but should ideally be applied at source level and rebuilt.

Code Example

// Before:
if (!sessionEntry) return "missing-session-entry";

// After:
if (!sessionEntry) {
    // Session store gone after run ended — expected cleanup, not an orphan.
    // prune only active/unended runs whose store is missing.
    if (typeof params.entry.endedAt === "number") return null;
    return "missing-session-entry";
}

---

task_runs row: cc24b894-d70b-46aa-97ee-1a0f3b27417a
status: succeeded, delivery_status: delivered
agent.wait: status=ok (not timeout)
parent received marker as non-empty output ✓
RAW_BUFFERClick to expand / collapse

Bug Description

Native subagent runs (via sessions_spawn runtime=subagent) complete successfully, but the parent agent never receives the child's output. The delivery_status field in task_runs remains pending indefinitely, and agent.wait on the child session returns status=timeout with empty output.

Root Cause

Two separate failure points in the completion/capture/delivery pipeline:

Failure Point 1 — Result not captured before session cleanup (Hermes, fixed)

File: dist/subagent-registry-CdtzK4_R.js

When a subagent run completes, the wait.resultText (the assistant's final output text) exists only transiently in the child session state before that session store is cleaned up. The parent-side completion capture fired before the result was frozen, causing the delivery payload to be empty.

Fix: In freezeRunResultAtCompletion (called from the announce flow), capture wait.resultText durably before session cleanup. Added caching of assistant text by runId in server-methods-Dvr1K7zh.js and preservation of resultText/replyText in normalized wait results in run-wait-cmY6eTHK.js.

Failure Point 2 — Completed runs incorrectly identified as orphans (Operator, fixed)

File: dist/subagent-registry-CdtzK4_R.js

The function resolveSubagentRunOrphanReason returns "missing-session-entry" when the session store entry for a completed child run is missing. However, for completed runs (those with endedAt set), the session store is expected to be cleaned up after the run ends — this is normal cleanup, not an orphan condition. Only active/unended runs with missing session entries should be pruned.

Fix: In resolveSubagentRunOrphanReason, if sessionEntry is null AND entry.endedAt is set, return null (not an orphan) instead of "missing-session-entry":

// Before:
if (!sessionEntry) return "missing-session-entry";

// After:
if (!sessionEntry) {
    // Session store gone after run ended — expected cleanup, not an orphan.
    // prune only active/unended runs whose store is missing.
    if (typeof params.entry.endedAt === "number") return null;
    return "missing-session-entry";
}

Files Modified (dist patches — for reference only)

These are compiled/bundled dist files and not meant to be edited directly. The patches below are provided as reference implementations — they demonstrate the fix but should ideally be applied at source level and rebuilt.

FileChangeApplied by
subagent-registry-CdtzK4_R.jsFreeze resultText + orphan check fixHermes + Operator
server-methods-Dvr1K7zh.jsCache assistant text by runIdHermes
run-wait-cmY6eTHK.jsPreserve resultText/replyText in normalized waitHermes
agent-runner.runtime-CjYlXxbm.jsEmit CLI final text as resultText on lifecycle endHermes

Verification

Smoke test with marker SUBAGENT_E2E_FIXED_173504:

task_runs row: cc24b894-d70b-46aa-97ee-1a0f3b27417a
status: succeeded, delivery_status: delivered
agent.wait: status=ok (not timeout)
parent received marker as non-empty output ✓

DB Cleanup

5 stale rows with runtime=subagent, status=succeeded, delivery_status=pending (orphaned before fix) were updated to delivery_status=delivered.

Environment

  • OpenClaw 2026.5.5 (macOS Darwin, node v22.22.1)
  • Runtime: native subagent via sessions_spawn runtime=subagent
  • Task DB: ~/.openclaw/tasks/runs.sqlite

Expected Behavior (after fix)

  1. Child subagent run completes → status=succeeded
  2. delivery_status transitions to delivered (not stuck at pending)
  3. Parent agent's agent.wait returns status=ok with the child's output text
  4. No orphan pruning of completed runs at restore time

Suggested Source-Level Fix

For the orphan-check issue specifically, the fix in resolveSubagentRunOrphanReason is a one-liner at the session-entry null check — add the endedAt guard to return null for completed runs. For the result capture issue, the proper fix requires ensuring wait.resultText is captured and frozen before session cleanup in the lifecycle flow.

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: native subagent completion output not delivered to parent agent (delivery_status stuck on 'pending') [1 comments, 2 participants]