[BUG] Background Bash task notifications persist as "running" after processes complete/fail/killed
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
KillShellreturns 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:
- Start multiple background Bash commands (e.g.,
sshorrsyncto remote hosts) - Let them complete, timeout, or fail
- Observe system reminders continue showing them as "running"
- 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:
- 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
- The
BashOutputtool should report correct status on first check (not requireKillShellto
reveal true state)
- Ideally: Provide a
/clear-background-taskscommand 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):
- In Claude Code, run a background Bash command:
````
Bash tool with run_in_background: true
command: "sleep 5 && echo done"
- Wait 10+ seconds for it to complete
- Send another message to Claude
- Observe: System reminder still shows
(status: running) Has new output available - Attempt
KillShellon the shell ID - KillShell returns:
"Shell X is not running, so cannot be killed (status: completed)" - Send another message
- Bug: System reminder STILL shows
(status: running)despite step 6 confirming completion
Multi-process reproduction (more severe):
- Launch 5+ background commands (ssh, rsync, or any commands)
- Let some complete, some fail (e.g., connection timeout), kill some manually
- Continue conversation for several messages
- Observe: ALL processes show
(status: running)in system reminders regardless of actual state - 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
This issue has 3 comments on GitHub. Read the full discussion on GitHub ↗