BashOutput shows stale 'running' status for completed/killed shells

Resolved 💬 3 comments Opened Dec 4, 2025 by asheppard47 Closed Dec 8, 2025

Environment

  • Claude Code version: Latest (December 2024)
  • OS: macOS Darwin 25.1.0 (Mac Mini M4)
  • Shell: zsh

Description

BashOutput tool continues to show shells as "running" with "Has new output available" system reminders even after:

  1. The shell process has completed
  2. The shell has been explicitly killed via KillShell
  3. The underlying Python process no longer exists

This creates a feedback loop where Claude keeps receiving system reminders about "running" shells that don't exist, polluting the context and making it impossible to track actual background processes.

Steps to Reproduce

  1. Run a command in background:
python3 -c "print('test')" 2>&1

(Claude Code auto-backgrounds this)

  1. Wait for completion or kill the shell with KillShell
  1. Observe that system reminders continue appearing:
<system-reminder>
Background Bash XXXXXX (command: ...) (status: running) Has new output available.
</system-reminder>
  1. KillShell returns "Shell XXXXXX is not running, so cannot be killed (status: killed)" but the reminders persist

Expected Behavior

  • Completed shells should show status: completed and stop generating reminders
  • Killed shells should be removed from tracking entirely
  • BashOutput should return actual current status, not cached state

Actual Behavior

  • Shells show status: running indefinitely
  • System reminders accumulate (saw 9+ stale shell reminders in one session)
  • KillShell confirms shells are dead but reminders continue
  • BashOutput returns empty content or (No content) for these ghost shells
  • Only fix is to restart Claude Code session entirely

Impact

  • High severity for debugging workflows: When investigating issues requiring multiple background processes, the stale reminders make it impossible to track which processes are actually running
  • Context pollution: Each stale reminder consumes context tokens
  • Confusing UX: Claude keeps trying to check output of dead processes

Workaround

Restart Claude Code session to clear stale shell state. Avoid using background shells for long-running processes; use file-based output monitoring instead:

command &>/tmp/output.log &
# Poll for output file instead of using BashOutput

Session Evidence

In a single debugging session, accumulated 9 stale shell trackers that persisted through:

  • Multiple KillShell calls (all returned "not running" or "killed")
  • Process termination via pkill -9
  • 30+ minutes of elapsed time

The reminders only stopped after the session was terminated.

View original on GitHub ↗

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