Background Bash command reading other agents' output files can cause runaway disk usage (1.2TB)

Resolved 💬 5 comments Opened Mar 9, 2026 by magnetarai-founder Closed Apr 27, 2026

Bug Report

Summary

A background Bash command that reads from other background agents' .output files can cause runaway disk usage. In my case, it grew to 1.2TB before I manually killed it and deleted the file.

Reproduction Steps

  1. Launch multiple background agents (e.g., 6+ Agent tool invocations with run_in_background: true)
  2. While those agents are running, launch a background Bash command that reads their output files:

``bash
# This was the actual command that caused the issue
for f in /private/tmp/claude-501/.../tasks/*.output; do
echo "=== $(basename $f) ==="
tail -3 "$f" 2>/dev/null || echo "(empty)"
done
``

  1. The background Bash command's own output file grows unboundedly as it captures the streaming JSONL from the still-running agents.

Expected Behavior

  • Background command output files should have a size cap or circuit breaker
  • Or: tail on actively-growing files should not stream indefinitely into the output capture

Actual Behavior

  • The output file at /private/tmp/claude-501/.../tasks/<id>.output grew to 1.2TB
  • No automatic size limit or warning was applied
  • Had to manually discover and delete the file

Environment

  • Claude Code v2.1.71
  • macOS Darwin 25.3.0
  • Model: claude-opus-4-6

Suggested Mitigations

  1. Output file size cap: Kill background commands if their output file exceeds a threshold (e.g., 100MB)
  2. Warning on large output: Surface a warning when a background task's output exceeds a reasonable size
  3. Prevent self-referential reads: Detect when a background command is reading from the same /tmp/claude-*/tasks/ directory where other tasks are writing

🤖 Generated with Claude Code

View original on GitHub ↗

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