[BUG] Background task output files grow without limit, can fill disk after session crash

Resolved 💬 4 comments Opened Mar 10, 2026 by travtex Closed Apr 15, 2026

Preflight Checklist

  • [x] I have searched existing issues and this hasn't been reported yet
  • [x] This is a single bug report (please file separate reports for different bugs)
  • [x] I am using the latest version of Claude Code

What's Wrong?

Bug

Background tasks (created via TaskCreate / run_in_background) write their output to .output files under /private/tmp/claude-<uid>/<project-path>/tasks/. These files have no size cap. If
a task produces unbounded output and the parent session crashes, the orphaned task continues running and writing indefinitely.

Impact

A single runaway task grew its output file to 2.5 TiB, nearly filling a 3.6 TiB drive. The file had to be manually tracked down and deleted.

Reproduction

  1. Start a Claude Code session on any project
  2. A background task is spawned (agent or run_in_background bash command) that produces continuous/unbounded stdout
  3. Parent session crashes (OOM, context overflow, etc.)
  4. Orphaned task continues writing to its .output file with no limit
  5. Disk fills up

Observed file location

/private/tmp/claude-501/-Users-<user>-<project-path>/tasks/<task-id>.output

Expected behavior

  • Task output files should have a maximum size cap (e.g. rotate, truncate, or stop writing after a threshold)
  • Child/background tasks should be killed when the parent session exits or crashes
  • Ideally, some form of disk usage monitoring or circuit breaker should prevent a single task from consuming unbounded disk space

Environment

  • macOS (Darwin 25.3.0)
  • APFS filesystem
  • Claude Code CLI

What Should Happen?

Bug

Background tasks (created via TaskCreate / run_in_background) write their output to .output files under /private/tmp/claude-<uid>/<project-path>/tasks/. These files have no size cap. If
a task produces unbounded output and the parent session crashes, the orphaned task continues running and writing indefinitely.

Impact

A single runaway task grew its output file to 2.5 TiB, nearly filling a 3.6 TiB drive. The file had to be manually tracked down and deleted.

Observed file location

/private/tmp/claude-501/-Users-<user>-<project-path>/tasks/<task-id>.output

Expected behavior

  • Task output files should have a maximum size cap (e.g. rotate, truncate, or stop writing after a threshold)
  • Child/background tasks should be killed when the parent session exits or crashes
  • Ideally, some form of disk usage monitoring or circuit breaker should prevent a single task from consuming unbounded disk space

Environment

  • macOS (Darwin 25.3.0)
  • APFS filesystem
  • Claude Code CLI

Error Messages/Logs

Steps to Reproduce

Reproduction

  1. Start a Claude Code session on any project
  2. A background task is spawned (agent or run_in_background bash command) that produces continuous/unbounded stdout
  3. Parent session crashes (OOM, context overflow, etc.)
  4. Orphaned task continues writing to its .output file with no limit
  5. Disk fills up

Claude Model

Opus

Is this a regression?

I don't know

Last Working Version

_No response_

Claude Code Version

2.1.72

Platform

Anthropic API

Operating System

macOS

Terminal/Shell

iTerm2

Additional Information

<img width="501" height="141" alt="Image" src="https://github.com/user-attachments/assets/77821069-acec-4a5a-ac29-1f39eb1c9de9" />

View original on GitHub ↗

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