claude-code - 💡(How to fix) Fix Task output file grows unbounded in infinite append loop [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
anthropics/claude-code#45015Fetched 2026-04-09 08:15:20
View on GitHub
Comments
1
Participants
2
Timeline
5
Reactions
0
Timeline (top)
labeled ×4commented ×1

When using the Agent tool to spawn parallel subagents during autonomous (headless) sessions, the task output aggregator file in /tmp/claude-{uid}/{project-path}/tasks/ can enter an infinite append loop, repeating the same subagent output block until the disk fills.

Error Message

Two separate sessions produced runaway task output files:

  • bz9w6d6ad.output68 GB, 27 million lines
  • bgegkjhpy.output44 GB

Root Cause

When using the Agent tool to spawn parallel subagents during autonomous (headless) sessions, the task output aggregator file in /tmp/claude-{uid}/{project-path}/tasks/ can enter an infinite append loop, repeating the same subagent output block until the disk fills.

Fix Action

Workaround

Manually delete /tmp/claude-{uid}/ periodically. The data is duplicated (subagent results are also in the session trace JSONL), so nothing is lost.

Code Example

=== a1262b6bb7e82b70c.output ===
{...agent output, WebSearch for "Ad Astra Rocket VASIMR"...}
{...tool_result [3262 chars]...}
=== a5bbe0730e77f4b60.output ===
{...agent output, WebSearch for "Near Space Corporation"...}
=== ad2b4bc8828aaf0ea.output ===
{...agent output, WebFetch...}
=== aebde00c8b22c13e4.output ===
{...agent output...}
=== bz9w6d6ad.output ===        <-- references itself
{...same tool_result [3160 chars]...}
{...same tool_result [2861 chars]...}
=== bz9w6d6ad.output ===        <-- repeats
{...same tool_result [3160 chars]...}
{...same tool_result [2861 chars]...}
(repeats millions of times)
RAW_BUFFERClick to expand / collapse

Description

When using the Agent tool to spawn parallel subagents during autonomous (headless) sessions, the task output aggregator file in /tmp/claude-{uid}/{project-path}/tasks/ can enter an infinite append loop, repeating the same subagent output block until the disk fills.

Reproduction context

  • Claude Code version: 2.1.92
  • Platform: macOS (Darwin 25.4.0, Apple Silicon)
  • Mode: Headless (--print --output-format stream-json)
  • Model: claude-opus-4-6
  • Trigger: Agent tool spawning 3-4 parallel subagents doing WebSearch/WebFetch/USASpending queries

Observed behavior

Two separate sessions produced runaway task output files:

  • bz9w6d6ad.output68 GB, 27 million lines
  • bgegkjhpy.output44 GB

The 68GB file structure:

=== a1262b6bb7e82b70c.output ===
{...agent output, WebSearch for "Ad Astra Rocket VASIMR"...}
{...tool_result [3262 chars]...}
=== a5bbe0730e77f4b60.output ===
{...agent output, WebSearch for "Near Space Corporation"...}
=== ad2b4bc8828aaf0ea.output ===
{...agent output, WebFetch...}
=== aebde00c8b22c13e4.output ===
{...agent output...}
=== bz9w6d6ad.output ===        <-- references itself
{...same tool_result [3160 chars]...}
{...same tool_result [2861 chars]...}
=== bz9w6d6ad.output ===        <-- repeats
{...same tool_result [3160 chars]...}
{...same tool_result [2861 chars]...}
(repeats millions of times)

The file appears to concatenate the individual subagent .output symlinks into a single aggregated file, but enters a loop where it re-reads its own output (the === bz9w6d6ad.output === section references the aggregator file's own name), causing infinite self-appending.

Expected behavior

The task output aggregator should write each subagent's output once and stop. It should not reference or re-read its own file.

Impact

  • Silently fills disk during long-running autonomous sessions
  • No error or warning produced
  • In our case: 108 GB consumed across 2 sessions on a 228 GB disk (reached 92% capacity)
  • Files persist in /tmp/ across sessions and are never cleaned up

Workaround

Manually delete /tmp/claude-{uid}/ periodically. The data is duplicated (subagent results are also in the session trace JSONL), so nothing is lost.

extent analysis

TL;DR

The issue can be mitigated by manually deleting the /tmp/claude-{uid}/ directory periodically to prevent disk fill-up due to infinite append loops in task output aggregator files.

Guidance

  • Identify and monitor the size of task output aggregator files in /tmp/claude-{uid}/{project-path}/tasks/ to detect potential infinite append loops.
  • Implement a periodic cleanup mechanism for /tmp/claude-{uid}/ directories to prevent disk space issues, considering the data is duplicated in session trace JSONL files.
  • Review the Agent tool's logic for spawning parallel subagents and task output aggregation to prevent self-referential loops.
  • Consider adding error handling or warnings for cases where the task output aggregator detects a self-referential loop or excessive file growth.

Example

No specific code example is provided due to the lack of explicit code references in the issue description.

Notes

The provided workaround of manually deleting /tmp/claude-{uid}/ directories is a temporary solution. A more permanent fix would involve modifying the Agent tool to correctly handle task output aggregation and prevent self-referential loops.

Recommendation

Apply the workaround of periodically deleting /tmp/claude-{uid}/ directories, as it is a safe and effective way to mitigate the issue until a permanent fix can be implemented.

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

The task output aggregator should write each subagent's output once and stop. It should not reference or re-read its own file.

Still need to ship something?

×6

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

Back to top recommendations

TRENDING