[BUG] Background Bash task notifications persist as "running" after processes complete/fail/killed

Resolved 💬 3 comments Opened Dec 15, 2025 by eprincipe01 Closed Dec 19, 2025

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?

Description:
Background Bash processes started with run_in_background: true continue to display system reminders indicating (status: running) Has new output available even after the processes have completed, failed, or been killed.

Observed Behavior:

  • System reminders persistently show background tasks as "running"
  • Attempting KillShell returns status like:
  • "Shell X is not running, so cannot be killed (status: killed)"
  • "Shell X is not running, so cannot be killed (status: completed)"
  • "Shell X is not running, so cannot be killed (status: failed)"
  • Despite these responses confirming processes are dead, the "running" reminders persist in subsequent messages

Reproduction Steps:

  1. Start multiple background Bash commands (e.g., ssh or rsync to remote hosts)
  2. Let them complete, timeout, or fail
  3. Observe system reminders continue showing them as "running"
  4. Attempt KillShell - returns correct dead status but reminders persist

Evidence from session:
14 background processes showed as "running" but KillShell revealed:

  • 13 processes: status: completed/failed/killed
  • 1 process: Actually running (was killed successfully)

Impact:

  • Context pollution from persistent stale reminders
  • Contributes to frequent context compaction
  • No programmatic way to clear the stale notifications

Expected Behavior:
System reminders should sync with actual process status. Dead processes should not display "(status: running)".

Environment:

  • Platform: Linux (RHEL 9)
  • Claude Code version: Current as of 2025-12-14

What Should Happen?

Expected Behavior:

  1. When a background process completes/fails/is killed, the system reminder should:
  • Either update to show (status: completed/failed/killed) instead of (status: running)
  • Or be removed entirely from subsequent messages
  1. The BashOutput tool should report correct status on first check (not require KillShell to

reveal true state)

  1. Ideally: Provide a /clear-background-tasks command or equivalent to purge stale notifications

manually

Error Messages/Logs

● Let me get actual status from some of these "running" tasks to include as evidence:

● Kill Shell(Kill shell: 290412)
  ⎿  Error: Shell 290412 is not running, so cannot be killed (status: killed)

● Kill Shell(Kill shell: 979042)
  ⎿  Error: Shell 979042 is not running, so cannot be killed (status: completed)

● Kill Shell(Kill shell: eeb03f)
  ⎿  Error: Shell eeb03f is not running, so cannot be killed (status: completed)

● Kill Shell(Kill shell: 93fcaf)
  ⎿  Error: Shell 93fcaf is not running, so cannot be killed (status: killed)

● There's the evidence. The system reminders STILL show "(status: running)" in this very response
  despite KillShell confirming they're dead.

Steps to Reproduce

Reproduction Steps:

Minimal reproduction (single command):

  1. In Claude Code, run a background Bash command:

``
Bash tool with run_in_background: true
command: "sleep 5 && echo done"
``

  1. Wait 10+ seconds for it to complete
  2. Send another message to Claude
  3. Observe: System reminder still shows (status: running) Has new output available
  4. Attempt KillShell on the shell ID
  5. KillShell returns: "Shell X is not running, so cannot be killed (status: completed)"
  6. Send another message
  7. Bug: System reminder STILL shows (status: running) despite step 6 confirming completion

Multi-process reproduction (more severe):

  1. Launch 5+ background commands (ssh, rsync, or any commands)
  2. Let some complete, some fail (e.g., connection timeout), kill some manually
  3. Continue conversation for several messages
  4. Observe: ALL processes show (status: running) in system reminders regardless of actual state
  5. Each dead process adds ~200-500 bytes of context pollution per message

Evidence from session (reproducible):

Attempted to kill 4 processes that show (status: running) in system reminders:

KillShell(290412) → "Shell 290412 is not running, so cannot be killed (status: killed)"
KillShell(979042) → "Shell 979042 is not running, so cannot be killed (status: completed)"
KillShell(eeb03f) → "Shell eeb03f is not running, so cannot be killed (status: completed)"
KillShell(93fcaf) → "Shell 93fcaf is not running, so cannot be killed (status: killed)"

Critically: In the SAME response where KillShell confirms these are dead, the system reminders STILL display:

<system-reminder>
Background Bash 290412 (command: rsync...) (status: running) Has new output available.
</system-reminder>

The contradiction is immediate and demonstrable within a single API response

Impact:

  • Context pollution from persistent stale reminders
  • Contributes to frequent context compaction
  • No programmatic way to clear the stale notifications

Claude Model

Not sure / Multiple models

Is this a regression?

I don't know

Last Working Version

_No response_

Claude Code Version

● Versions: - Claude Model: Opus 4.5 (claude-opus-4-5-20251101) - Claude Code CLI: 2.0.69

Platform

Anthropic API

Operating System

Other Linux

Terminal/Shell

Xterm

Additional Information

Environment:

  • Platform: Linux (RHEL 9)
  • Shell: Bash (/bin/bash)
  • Terminal: xterm-256color
  • Claude Code CLI version: 2.0.69
  • Claude Model: Opus 4.5 (claude-opus-4-5-20251101)
  • Date: 2025-12-15

---
Note: As you can see from this very response, there are 22+ stale background process reminders
appearing - all showing (status: running) even though they're demonstrably dead. This is live
evidence of the bug.

2025-12-15 10:55:42 EST

View original on GitHub ↗

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