Task output files grow exponentially via self-referential inclusion
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
- Run any multi-agent workflow that dispatches several parallel subagents (e.g., a code review skill that spawns ~7 specialist agents)
- The session creates individual
.outputfiles per agent undertasks/ - 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 devicevisible in the file tail) - All of this from a code review of a 23-line, 2-file PR
- The individual agent
.outputfiles 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: trueon 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
This issue has 2 comments on GitHub. Read the full discussion on GitHub ↗