Task output files grow exponentially via self-referential inclusion

Resolved 💬 2 comments Opened Mar 17, 2026 by jtsternberg Closed Apr 14, 2026

Bug Description

Task output files in /tmp/claude-{UID}/ can grow to hundreds of gigabytes via a self-referential inclusion bug, filling the disk entirely.

Reproduction

  1. Run any multi-agent workflow that dispatches several parallel subagents (e.g., a code review skill that spawns ~7 specialist agents)
  2. The session creates individual .output files per agent under tasks/
  3. Two "aggregator" task output files are also created

What Happens

The aggregator output files dump ALL task outputs in the session using this format:

========== agent_aaa.output ==========
{...json transcript of agent_aaa...}
========== agent_bbb.output ==========
{...json transcript of agent_bbb...}
========== agent_ccc.output ==========
{...json transcript of agent_ccc...}
========== aggregator_xxx.output ==========    <-- THE AGGREGATOR'S OWN FILE
{...its own growing content gets included here...}
========== agent_aaa.output ==========          <-- cycle repeats
{...json transcript of agent_aaa...}
========== agent_bbb.output ==========
...

The aggregator file includes its own content in the dump. Each write cycle appends all previous content plus itself, causing exponential growth:

  • Cycle 1: ~5MB (7 agent outputs + empty self)
  • Cycle 2: ~10MB (7 agent outputs + 5MB self)
  • Cycle 3: ~20MB (7 agent outputs + 10MB self + 5MB agents)
  • ...doubling each cycle

Observed Impact

  • Two aggregator files grew to 209 GB and 94 GB respectively (303 GB total)
  • Disk filled completely (cat: stdout: No space left on device visible in the file tail)
  • All of this from a code review of a 23-line, 2-file PR
  • The individual agent .output files were 0 bytes each — all the content was being funneled into the aggregator files
  • Session was on Claude Code v2.1.75, claude-opus-4-6

Expected Behavior

The task output aggregation should exclude the aggregator's own .output file from the dump to prevent self-referential growth.

Additional Context

  • Platform: macOS (Darwin)
  • The files were located at: /tmp/claude-{UID}/{project-path}/{session-uuid}/tasks/{task-id}.output
  • The 7 individual agent output files were all 0 bytes
  • The session had isSidechain: true on all messages, indicating these were background subagent tasks
  • The exponential pattern is clearly visible by scanning for the ========== section headers, which repeat in a fixed cycle (7 agents + self = 8 sections, repeating hundreds of thousands of times)

Suggested Fix

When writing aggregated task output, skip any file whose path matches the output file currently being written to. A simple filename/path check before inclusion would prevent the recursion entirely.

🤖 Generated with Claude Code

View original on GitHub ↗

This issue has 2 comments on GitHub. Read the full discussion on GitHub ↗