[BUG] Background shell reminders persist for completed shells, cannot be cleared
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 shells that have completed continue to generate <system-reminder> messages on every turn, consuming context rapidly.
The KillShell tool reports the shells as "completed" or "failed" but the reminders persist.
Expected Behavior
- Completed shells should not generate reminders
- OR KillShell should remove completed shells from tracking
- OR /clear should reset shell tracking state
Actual Behavior
- 50+ completed shells generate reminders every turn
- Each reminder consumes ~200 tokens
- Context fills rapidly (10k+ tokens/turn just from stale reminders)
- No way to clear them without starting a new session
Environment
- Claude Code CLI
- macOS Darwin 25.1.0
- Session resumed from previous conversation
Impact
Severe context bloat makes long sessions unusable. Users must start new sessions to escape accumulated shell reminders.
What Should Happen?
Expected Behavior
Option A (Preferred): Completed shells should automatically stop generating reminders. Once a shell exits (status: completed/failed), it should be removed from the reminder system.
Option B: KillShell should work on completed shells - not to kill the process, but to remove them from tracking. Currently it only operates on running processes.
Option C: Provide a /clear-shells command or have /clear also reset shell tracking state.
Why This Matters
Each reminder is ~200 tokens. With 52 stale shells, that's 10,400+ tokens per turn consumed by reminders for processes that finished long ago. This makes continued conversation impractical.
---
TL;DR for the issue: Shells should stop generating reminders after they complete, or users need a way to manually remove completed shells from tracking.
Error Messages/Logs
KillShell tool response (for all 52 shells):
Shell 347829 is not running, so cannot be killed (status: completed)
Shell 473051 is not running, so cannot be killed (status: completed)
Shell 49fa25 is not running, so cannot be killed (status: failed)
... (52 similar responses)
System reminder still showing (same turn, after KillShell):
<system-reminder>
Background Bash 347829 (command: ...) (status: running) Has new output available.
</system-reminder>
Key inconsistency: KillShell reports status: completed, but system-reminder shows status: running. The shell tracking state is
inconsistent between these two systems.
---
This shows the bug clearly: KillShell knows the shells are done, but the reminder system doesn't sync with that state.
Steps to Reproduce
Steps to Reproduce
- Run multiple background commands over a session:
uv run python -m myapp 2>&1 &
- Let the commands complete naturally
- Observe system reminders continue appearing every turn:
<system-reminder>
Background Bash abc123 (command: ...) (status: running) Has new output available.
</system-reminder>
- Attempt to kill shells with KillShell tool
- KillShell reports: Shell abc123 is not running, so cannot be killed (status: completed)
- Reminders continue appearing despite shell being completed
Claude Model
Opus
Is this a regression?
I don't know
Last Working Version
_No response_
Claude Code Version
2.0.55 (Claude Code)
Platform
Anthropic API
Operating System
macOS
Terminal/Shell
Warp
Additional Information
_No response_
This issue has 4 comments on GitHub. Read the full discussion on GitHub ↗