openclaw - ✅(Solved) Fix [Bug]: Subagent result not delivered to parent session (sessions_spawn with claude) [1 pull requests, 2 comments, 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#43755Fetched 2026-04-08 00:17:41
View on GitHub
Comments
2
Participants
1
Timeline
8
Reactions
0
Author
Participants
Timeline (top)
cross-referenced ×3commented ×2labeled ×2referenced ×1

When using sessions_spawn to call claude subagent, the result is captured by gateway but not delivered to parent session, showing (no output) instead of actual content.

Root Cause

When using sessions_spawn to call claude subagent, the result is captured by gateway but not delivered to parent session, showing (no output) instead of actual content.

Fix Action

Fixed

PR fix notes

PR #43965: fix(agents): improve subagent output extraction for edge cases

Description (problem / solution / changelog)

Summary

Fixes #43755

Problem

When using sessions_spawn to call claude subagent, the result is captured by gateway but not delivered to parent session, showing (no output) instead of actual content.

Root Cause

The extractSubagentOutputText() function may not handle all message formats correctly. When subagent results are stored in different formats (user role, or with different content fields), the extraction fails and returns empty string.

Solution

Added more fallback handling in extractSubagentOutputText():

  • Try user role as fallback (results might be in user messages)
  • Check for raw "result" field at message root
  • Check for "output" field at message root
  • Handle more edge cases

Test

  1. Use sessions_spawn(agentId="claude", task="...") in main session
  2. Wait for subagent to complete
  3. Parent session should receive actual result instead of (no output)

Changed files

  • src/agents/subagent-announce.ts (modified, +30/-0)
RAW_BUFFERClick to expand / collapse

Bug type

Behavior bug (incorrect output/state without crash)

Summary

When using sessions_spawn to call claude subagent, the result is captured by gateway but not delivered to parent session, showing (no output) instead of actual content.

Steps to reproduce

  1. Use sessions_spawn(agentId="claude", model="opus", task="...") in main session
  2. Wait for subagent to complete (visible in logs: agent.wait completes with full result)
  3. Parent session receives subagent_announce with Result: (no output) instead of actual result

Expected behavior

Parent session receives the full result from subagent via subagent_announce event.

Actual behavior

  • Gateway logs show: ⇄ res ✓ agent.wait 78236ms with complete result in JSON
  • Main session receives: Result (untrusted content): <<<BEGIN_UNTRUSTED_CHILD_RESULT>>>(no output <<<END_UNTRUSTED_CHILD_RESULT>>>
  • This happened on both spawn attempts (first with timeoutSeconds, second with runTimeoutSeconds=120)

OpenClaw version

2026.3.11

Operating system

Windows 11

Install method

npm global

Model

bailian/MiniMax-M2.5 (main session) → claude-cli/opus (subagent)

Provider / routing chain

sessions_spawn → claude subagent (claude-cli)

Config file / key location

All files are listed in the attachment below.

Additional provider/model setup details

All files are attached.

openclaw.multi-agent.template.json.txt

01_console-output.redacted.txt 02_subagents-run.redacted.json.txt 03_gateway-log.redacted.jsonl.txt 04_session-trace.redacted.jsonl.txt 05_config-audit.redacted.jsonl.txt 06_test-log.redacted.txt

Logs, screenshots, and evidence

Impact and severity

  • Severity: Blocks workflow - cannot get subagent results reliably
  • Frequency: Always - both test attempts failed to deliver result
  • Consequence: User cannot trust subagent output; must manually check logs to retrieve results; blocks automated workflows relying on subagent output

Additional information

Logs confirm result exists in gateway ("result":"XX\n- ...") but isn't propagated First attempt: timeout after 60s (my bug - used wrong param) Second attempt with correct param (runTimeoutSeconds=120) also failed to deliver result despite success in gateway This suggests subagent_announce event parsing or session message routing bug

extent analysis

Fix Plan

To resolve the issue of the subagent result not being delivered to the parent session, we need to modify the sessions_spawn function to correctly handle the result from the gateway.

Here are the steps:

  • Update the sessions_spawn function to parse the result from the gateway correctly.
  • Ensure the subagent_announce event is triggered with the correct result.

Example code snippet:

def sessions_spawn(agentId, model, task, runTimeoutSeconds=120):
    # ... existing code ...
    result = agent.wait(runTimeoutSeconds)
    # Parse the result from the gateway
    result = json.loads(result)
    # Trigger the subagent_announce event with the correct result
    subagent_announce_event = {
        'type': 'subagent_announce',
        'result': result
    }
    # ... existing code to send the event to the parent session ...

Verification

To verify that the fix worked, you can:

  • Run the sessions_spawn function with the updated code.
  • Check the parent session logs to ensure the subagent_announce event is received with the correct result.
  • Verify that the result is displayed correctly in the parent session.

Extra Tips

  • Ensure that the agent.wait function is correctly waiting for the result from the gateway.
  • Verify that the result is being parsed correctly from the gateway response.
  • Check the gateway logs to ensure that the result is being sent correctly to the parent session.

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…

FAQ

Expected behavior

Parent session receives the full result from subagent via subagent_announce event.

Still need to ship something?

×6

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

Back to top recommendations

TRENDING