[BUG] Finished background bash jobs generate infinite system reminders, wasting context tokens
[BUG] Finished background bash jobs generate infinite system reminders, wasting context tokens
Description
Background bash processes that have finished (status: failed or completed) continue generating system reminders indefinitely throughout the conversation, wasting significant context tokens.
Version
- Claude Code: 2.0.35
- Platform: macOS (Darwin 25.0.0)
- Installation: Homebrew cask + Direct download
Steps to Reproduce
- Start a background bash process:
./k8s.sh openprojectwithrun_in_background=true - Let the process complete (either successfully or with failure)
- Verify the process has finished:
BashOutputshows<status>failed</status>or<status>completed</status> - Continue the conversation with additional requests
- Observe system reminders appearing in every subsequent response
Expected Behavior
Once a background bash job has completed (regardless of exit status), it should:
- Stop generating system reminders
- Be removed from active job tracking
- Not waste context tokens with repeated notifications
Actual Behavior
Finished background jobs continue generating system reminders like:
<system-reminder>Background bash job 'a7cc15' is still running. Use BashOutput
to check its progress or KillShell to terminate it.</system-reminder>
These reminders appear in every single assistant response, even though:
- The job finished hours ago
BashOutputconfirms status isfailedorcompletedKillShellreturns error: "Shell a7cc15 is not running, so cannot be killed"
Impact
- Severe context token waste: Each reminder consumes tokens across multiple responses
- User experience degradation: Constant irrelevant reminders
- Cannot clear finished jobs: No way to dismiss completed background tasks
Example Session
In a recent session, two background jobs (a7cc15, 3d68b1) finished early but generated reminders for 2+ hours across 50+ responses, wasting thousands of context tokens.
Workaround
Current workaround is to avoid run_in_background: true entirely and use foreground processes with longer timeouts:
IMPORTANT: Avoid using background bash processes (run_in_background=true) due to a bug
where finished jobs continue sending reminders and waste context. Prefer foreground
processes with appropriate timeouts.
Related Issues
- #10210 - Background tasks not properly notified when complete
- #9478 - BashOutput returning complete logs instead of incremental
- #6854 - Feature request for background task notification system
Proposed Solution
- Track background job lifecycle states properly
- Remove finished jobs from reminder system
- Provide explicit tool to dismiss/clear completed background jobs
- Add
statusfield check before generating reminders (skip ifcompletedorfailed)
This issue has 2 comments on GitHub. Read the full discussion on GitHub ↗