Background Bash task output file can grow unbounded and fill disk

Resolved 💬 3 comments Opened Mar 7, 2026 by ahmedatitto-cpu Closed Mar 10, 2026

Bug Description

When a background Bash command (run_in_background: true) writes output that reads from growing/live files (e.g., agent transcript .jsonl files via symlinks), the output file grows without any size limit. In my case, it reached 310 GB before the background task completed.

Steps to Reproduce

  1. Launch multiple background agents (Agent tool with run_in_background: true)
  2. While agents are still running, run a background Bash command that reads agent output files:

``bash
# The agent .output files are symlinks to live .jsonl transcript files
for f in /private/tmp/claude-501/.../tasks/*.output; do tail -5 "$f"; done
``

  1. Since the Bash command runs in background, it has no timeout. The .jsonl files are being actively written to by the running agents, so the tail/cat keeps reading and the output file keeps growing.

Observed Behavior

  • The output file at /private/tmp/claude-501/<project>/tasks/<id>.output grew to 310 GB
  • It contained repeated dumps of agent transcript data (tool calls, file reads, etc.)
  • The file only stopped growing when the background agents completed

Expected Behavior

Background Bash task output files should have:

  • A maximum size cap (e.g., 10 MB or 100 MB) — truncate or stop writing after the limit
  • Or a timeout even for background tasks (e.g., 10 minutes max)
  • Or at minimum, detect when output is growing abnormally fast and kill the process

Impact

  • Can fill the user's entire disk, causing macOS to freeze (no swap space, no temp writes)
  • User may need a hard reboot if disk fills to 0%
  • No permanent damage, but extremely disruptive
  • User has no visibility into this happening — background tasks are silent

Environment

  • Claude Code CLI (latest)
  • macOS Darwin 25.3.0
  • The problematic files live in /private/tmp/claude-501/ (not in the user's project)

Workaround

Manually check and delete large files:

ls -lhS /private/tmp/claude-501/*/tasks/*.output

Everything in /private/tmp/ is safe to delete.

View original on GitHub ↗

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