Skip to content

[Bug]: Sub-agent dies with 'Network connection lost' during large tool call write — all work lost #43113

Closed as not planned

Description

@a1j9o94

Bug type

Network/streaming bug affecting sub-agents

Summary

Sub-agents that accumulate large context (600K-800K+ tokens) during research-heavy tasks consistently die with "Network connection lost" when attempting to write large file content via the write tool. All work is lost — no partial results persisted.

Steps to reproduce

  1. Spawn a sub-agent with a research-heavy task (e.g., "research X from primary sources and write a comprehensive report")
  2. The agent does extensive web_fetch calls, accumulating 600K+ tokens of context
  3. Agent attempts to write a large output file (10-20KB+) via the write tool
  4. Connection drops mid-write with errorMessage: "Network connection lost."
  5. No file is created, no partial output saved

Observed behavior

  • stopReason: "error" with errorMessage: "Network connection lost."
  • partialArgs shows the tool call started but never completed
  • File is not created (write never executed)
  • All research work is lost

Expected behavior

Environment

  • OpenClaw 2026.3.2
  • Provider: OpenRouter (anthropic/claude-opus-4.6)
  • macOS (arm64), local gateway mode
  • Happens consistently on sub-agents with 600K+ token context

Frequency

3/3 research-heavy sub-agents failed this way in one session. Short-context sub-agents (15-30K tokens) completed successfully.

Workaround

Split research tasks into two phases: (1) research agent saves raw notes to a file, (2) writer agent reads notes and compiles the final output. Keeps each agent's context small.

Related issues

Activity

  1. clawsweeper commented on Apr 26, 2026

    @clawsweeper
    Contributor

    Closing this as duplicate or superseded after Codex automated review.

    Close #43113 as duplicate/superseded by the newer open canonical issue #53540, which tracks the same large-context sub-agent/OpenRouter "Network connection lost" failure with stronger reproduction evidence. Current main has adjacent mitigations, but I did not find evidence that the exact reported streamed write-tool failure is fully fixed.

    What I checked:

    So I’m closing this here and keeping the remaining discussion on the canonical linked item.

    Codex Review notes: model gpt-5.5, reasoning high; reviewed against e640c0a95fcb.

  2. locked as resolved and limited conversation to collaborators on Apr 28, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    Priority

    None yet

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions