Bash tool background task captures 0 bytes when command completes successfully

Resolved 💬 1 comment Opened Mar 18, 2026 by h-aoki1623 Closed Mar 18, 2026

Description

When the Bash tool automatically backgrounds a long-running command, the output file remains 0 bytes even after the command completes successfully. The task output is lost entirely.

Steps to Reproduce

  1. Call the Bash tool with a long-running command and timeout: 600000:

``
make e2e-ios FLOW=voice-conversation.yaml 2>&1
``

  1. The tool returns a background task ID (e.g., b2prhow7g) and an output file path
  2. The command runs and completes successfully (observable externally — e.g., iOS Simulator shows test completion, Maestro process exits)
  3. Check the output file: it is 0 bytes

Expected Behavior

The output file should contain the command's stdout/stderr, and TaskOutput should return the captured output.

Actual Behavior

  • Output file exists but is 0 bytes
  • TaskOutput blocks indefinitely (the task appears stuck despite the process having exited)
  • The command itself executed correctly — only the output capture failed

Workaround

Re-run the same command without run_in_background, keeping it in foreground with the long timeout. This correctly captures all output.

Environment

  • Claude Code CLI
  • macOS (Darwin 24.6.0)
  • Model: claude-opus-4-6 (1M context)
  • The Bash tool auto-backgrounded the command (I did not set run_in_background: true explicitly)

Additional Context

The command was make e2e-ios FLOW=voice-conversation.yaml which runs Maestro E2E tests on an iOS Simulator. It typically takes 2-4 minutes. The process tree showed the Maestro process had already exited, and only a residual run-dev.sh --background process remained.

The second run (foreground, same timeout) captured output correctly and showed all tests passing.

View original on GitHub ↗

This issue has 1 comment on GitHub. Read the full discussion on GitHub ↗