Skip to content

Subagent run reports success but fails to write output file #86872

Description

@zapper35

Bug type

Behavior bug (incorrect output/state without crash)

Beta release blocker

No

Summary

Please note I am a complete numpty. This report generated by my OC.:

OpenClaw Subagent Failure Report

Date: 2026-05-26 11:14 UTC

  1. Executive Summary

A subagent tasked with performing a comprehensive security and architecture audit failed to produce its expected HTML report file. Despite the subagent indicating a successful completion, the target file was not found on the filesystem. Attempts to retrieve the subagent's detailed session history were blocked by system visibility restrictions.

  1. Subagent Task Details

The subagent was assigned a comprehensive audit task for the "xxx" system. The task included detailed instructions on the audit scope (security, architecture, data flows, customer experience), source code to analyze, and the required output format (HTML report to a specific path).

Target Output File: /xxx/xxx.html
Full Task Prompt Provided to Subagent:

You are a senior security and software engineer conducting a comprehensive audit of the "xxxx" system. Your job is to produce a detailed, professional HTML audit report and write it to /xxx/xxx.html.

  1. Sequence of Events

    [2026-05-26 10:23 UTC] Subagent spawned via sessions_spawn with the above task prompt.
    [2026-05-26 10:23 UTC] sessions_spawn returned:

    {
    "status": "accepted",
    "childSessionKey": "agent:main:subagent:68b3b1ba-b176-4f97-9ad6-ccccf84dca66",
    "runId": "7e45cdbd-f56f-46d0-9d64-2718aad37a4d",
    "mode": "run",
    "taskName": "marco_audit",
    "note": "Auto-announce is push-based. After spawning children, do NOT call sessions_list, sessions_history, exec sleep, or any polling tool. Track expected child session keys. Continue any independent work. If your final answer depends on child output, wait for runtime completion events to arrive as user messages and only answer after completion events for ALL required children arrive. If a child completion event arrives AFTER your final answer, reply ONLY with NO_REPLY.",
    "modelApplied": true
    }

    [2026-05-26 10:23 UTC] Main agent yielded waiting for subagent completion.
    [2026-05-26 11:10 UTC] Subagent completed (implicit completion event received, indicating success).
    [2026-05-26 11:10 UTC] Attempted to read the expected output file: /xxx/xxx.html
    [2026-05-26 11:10 UTC] read tool returned error:

    {
    "status": "error",
    "tool": "read",
    "error": "ENOENT: no such file or directory, access '/xxx/xxx.html'"
    }

    [2026-05-26 11:12 UTC] Attempted to fetch subagent history for diagnostics.
    [2026-05-26 11:12 UTC] sessions_history tool returned error:

    {
    "status": "forbidden",
    "error": "Session history visibility is restricted to the current session tree (tools.sessions.visibility=tree)."
    }

  2. Conclusion & Impact

The subagent run, despite reporting successful completion, failed to produce its intended output artifact. This indicates a potential issue within the subagent execution environment or its reporting mechanism, where the success state does not accurately reflect the completion of all specified subtasks, specifically file generation. The inability to retrieve session history further complicates post-mortem analysis of subagent failures, hindering debugging and accountability for developers.
5. Recommendation for OpenClaw Developers

**Investigate Subagent Output Reliability:** Examine the mechanism by which subagents report completion and ensure it accurately reflects the successful creation of all specified output files. Consider adding post-completion validation steps within the subagent framework to verify file existence/integrity when a file path is specified in the task.
**Enhance Subagent Debuggability:** Review and potentially relax the sessions_history visibility policy for the spawning agent, at least for a configurable debugging window post-failure. This would greatly assist in diagnosing issues by allowing access to internal tool calls and outputs of failed subagents.
**Improve Error Reporting:** Implement more granular error reporting from subagents, distinguishing between task execution failures and output generation failures.

Steps to reproduce

Please note I am a complete numpty. This report generated by my OC.:

OpenClaw Subagent Failure Report

Date: 2026-05-26 11:14 UTC

  1. Executive Summary

A subagent tasked with performing a comprehensive security and architecture audit failed to produce its expected HTML report file. Despite the subagent indicating a successful completion, the target file was not found on the filesystem. Attempts to retrieve the subagent's detailed session history were blocked by system visibility restrictions.

  1. Subagent Task Details

The subagent was assigned a comprehensive audit task for the "xxx" system. The task included detailed instructions on the audit scope (security, architecture, data flows, customer experience), source code to analyze, and the required output format (HTML report to a specific path).

Target Output File: /xxx/xxx.html
Full Task Prompt Provided to Subagent:

You are a senior security and software engineer conducting a comprehensive audit of the "xxxx" system. Your job is to produce a detailed, professional HTML audit report and write it to /xxx/xxx.html.

  1. Sequence of Events

    [2026-05-26 10:23 UTC] Subagent spawned via sessions_spawn with the above task prompt.
    [2026-05-26 10:23 UTC] sessions_spawn returned:

    {
    "status": "accepted",
    "childSessionKey": "agent:main:subagent:68b3b1ba-b176-4f97-9ad6-ccccf84dca66",
    "runId": "7e45cdbd-f56f-46d0-9d64-2718aad37a4d",
    "mode": "run",
    "taskName": "marco_audit",
    "note": "Auto-announce is push-based. After spawning children, do NOT call sessions_list, sessions_history, exec sleep, or any polling tool. Track expected child session keys. Continue any independent work. If your final answer depends on child output, wait for runtime completion events to arrive as user messages and only answer after completion events for ALL required children arrive. If a child completion event arrives AFTER your final answer, reply ONLY with NO_REPLY.",
    "modelApplied": true
    }

    [2026-05-26 10:23 UTC] Main agent yielded waiting for subagent completion.
    [2026-05-26 11:10 UTC] Subagent completed (implicit completion event received, indicating success).
    [2026-05-26 11:10 UTC] Attempted to read the expected output file: /xxx/xxx.html
    [2026-05-26 11:10 UTC] read tool returned error:

    {
    "status": "error",
    "tool": "read",
    "error": "ENOENT: no such file or directory, access '/xxx/xxx.html'"
    }

    [2026-05-26 11:12 UTC] Attempted to fetch subagent history for diagnostics.
    [2026-05-26 11:12 UTC] sessions_history tool returned error:

    {
    "status": "forbidden",
    "error": "Session history visibility is restricted to the current session tree (tools.sessions.visibility=tree)."
    }

  2. Conclusion & Impact

The subagent run, despite reporting successful completion, failed to produce its intended output artifact. This indicates a potential issue within the subagent execution environment or its reporting mechanism, where the success state does not accurately reflect the completion of all specified subtasks, specifically file generation. The inability to retrieve session history further complicates post-mortem analysis of subagent failures, hindering debugging and accountability for developers.
5. Recommendation for OpenClaw Developers

**Investigate Subagent Output Reliability:** Examine the mechanism by which subagents report completion and ensure it accurately reflects the successful creation of all specified output files. Consider adding post-completion validation steps within the subagent framework to verify file existence/integrity when a file path is specified in the task.
**Enhance Subagent Debuggability:** Review and potentially relax the sessions_history visibility policy for the spawning agent, at least for a configurable debugging window post-failure. This would greatly assist in diagnosing issues by allowing access to internal tool calls and outputs of failed subagents.
**Improve Error Reporting:** Implement more granular error reporting from subagents, distinguishing between task execution failures and output generation failures.

Expected behavior

produce .html report

Actual behavior

As above

OpenClaw version

.5.20

Operating system

W10

Install method

No response

Model

gemini

Provider / routing chain

gemini

Additional provider/model setup details

No response

Logs, screenshots, and evidence

Impact and severity

No response

Additional information

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Fields

    Priority

    None yet

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions