[BUG] Finished background bash jobs generate infinite system reminders, wasting context tokens

Resolved 💬 2 comments Opened Nov 7, 2025 by whimmel Closed Nov 7, 2025

[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

  1. Start a background bash process: ./k8s.sh openproject with run_in_background=true
  2. Let the process complete (either successfully or with failure)
  3. Verify the process has finished: BashOutput shows <status>failed</status> or <status>completed</status>
  4. Continue the conversation with additional requests
  5. 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
  • BashOutput confirms status is failed or completed
  • KillShell returns 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

  1. Track background job lifecycle states properly
  2. Remove finished jobs from reminder system
  3. Provide explicit tool to dismiss/clear completed background jobs
  4. Add status field check before generating reminders (skip if completed or failed)

View original on GitHub ↗

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