[BUG] Phantom bash session notifications persist after process completion

Resolved 💬 19 comments Opened Sep 11, 2025 by jahendricks Closed Feb 27, 2026

[BUG] Phantom bash session notifications persist after process completion

Preflight Checklist

  • [x] I have searched existing issues and this hasn't been reported yet
  • [x] This is a single bug report
  • [x] I am using the latest version of Claude Code

Environment Information

  • Platform: darwin (macOS)
  • OS: Darwin 24.6.0 (macOS Sequoia)
  • Architecture: ARM64 (Apple Silicon)
  • Terminal: Claude Code CLI
  • Bash Version: GNU bash 5.2.37(1)-release (aarch64-apple-darwin24.2.0)
  • Claude Code Version: 1.0.111
  • Date: 2025-09-11

Bug Description

Background bash sessions continue generating "new output available" system reminders even after the spawned processes have completed successfully. The sessions show status: running in notifications but return status: completed when accessed via KillBash tool.

Reproduction Steps

  1. Launch multiple background bash processes using Bash tool with run_in_background: true
  2. Processes complete successfully (spawning external Claude instances)
  3. Check session status with KillBash - returns status: completed
  4. System continues generating notifications: Background Bash [ID] (status: running) Has new output available
  5. No corresponding OS processes exist for the session IDs

Specific Session IDs Affected

  • 99f7b2, b23195, a08f32 (first batch - failed spawns)
  • b8196b, 37b623, b91aed (second batch - successful spawns)

Error Behavior

System Reminders (continuous):

Background Bash 99f7b2 (command: .ai/.orchestrator/spawn_phase_agent.sh .ai/ai-agent-stories/wave_04/tasks/TASK_PLATFORM_ADMIN_USER_STORIES.xml 1) (status: running) Has new output available. You can check its output using the BashOutput tool.

KillBash Response:

Shell 99f7b2 is not running, so cannot be killed (status: completed)

Process Check:

ps aux | grep -E "(99f7b2|b23195|a08f32)" 
# Returns no results - processes don't exist

Expected Behavior

  • Background bash sessions should clean up properly after process completion
  • No phantom notifications for completed sessions
  • KillBash should successfully terminate session tracking

Actual Behavior

  • Sessions remain in internal tracking as "running"
  • Continuous notification spam every few seconds
  • Session cleanup mechanism appears broken
  • Creates significant UX noise during orchestration workflows

Impact

  • High notification noise - makes Claude Code unusable for complex orchestration
  • Memory/resource tracking pollution - orphaned session references
  • User experience degradation - constant interruptions
  • Scalability issues - affects multi-agent orchestration systems

Additional Context

This issue is related to existing problems:

  • Issue #7069: Native Background Task Management System
  • Issue #6854: Non-blocking tasks / notification system
  • Issue #2550: Background bash commands

The sessions were used for spawning independent Claude processes via shell scripts. The spawner scripts completed successfully but the internal bash session manager didn't recognize completion.

Workaround Attempted

  • KillBash tool - ineffective (sessions already completed)
  • Process termination - no corresponding OS processes
  • Session cleanup - no available mechanism

Log Sample

BashOutput for phantom session 99f7b2:

<status>completed</status>
<exit_code>0</exit_code>
<stdout>
Launching Phase 1 of platform_admin_user_stories
[... successful spawn output ...]
</stdout>
<timestamp>2025-09-11T23:37:00.424Z</timestamp>

Note: Timestamp is from hours ago but notifications are current.

View original on GitHub ↗

19 Comments

jahendricks · 10 months ago

Workaround Discovery

During further testing, we discovered a partial workaround that prevents creating NEW phantom sessions:

Clean Approach (No New Phantoms)

Task tool subprocess execution:

Task tool → claude -p "command" --output-format stream-json --verbose

Problematic Approach (Creates Phantoms)

Direct Bash tool with background:

Bash tool → run_in_background: true

Test Results

  • Executed 3 parallel Task tool subprocesses successfully
  • Zero new phantom sessions created despite multiple subprocess executions
  • Original 6 phantom sessions (99f7b2, b23195, a08f32, b8196b, 37b623, b91aed) persist unchanged
  • Task tool approach keeps orchestration context noise-free

Implications

  1. Root cause confirmed: Issue is with Bash tool background session cleanup, not general subprocess execution
  2. Mitigation available: Task tool subprocess execution avoids adding to the phantom session pool
  3. Context management: Critical for complex multi-agent orchestration workflows where notification noise is disruptive

This workaround allows continued orchestration development while waiting for the core session cleanup fix.

EdanStarfire · 10 months ago

I'm seeing the same exact thing. It also persists across /clear even after the background tasks have ended.

> /clear 
  ⎿  (no content)

> are there any background tasks still running (either via status or via system reminders)?

● Yes, there are 4 background bash tasks still running based on the system reminders:

● BashOutput(Reading shell output)
  ⎿  The Boston Bruins' first preseason game for the 2024-25 NHL season was:

     **Date:** Sunday, September 22, 2024
     … +5 lines (ctrl+r to expand)

● BashOutput(Reading shell output)
  ⎿  The Edmonton Oilers' first preseason game for the 2024-25 NHL season was:

     **Date:** September 22, 2024
     … +3 lines (ctrl+r to expand)

● BashOutput(Reading shell output)
  ⎿  The Tampa Bay Lightning's first preseason game for the 2024-25 NHL season was:

     **Date:** September 24, 2024
     … +3 lines (ctrl+r to expand)

● BashOutput(Reading shell output)
  ⎿ Based on the official NHL information, here are the details for the Colorado Avalanche's first preseason game of the 2024-25 season
    :
    … +6 lines (ctrl+r to expand)


● All 4 background tasks have completed and show as "completed" status, but the system reminders still show them as "running". The tasks    
   have finished their work - they found the first preseason game information for:

  - Boston Bruins: Sept 22, 2024 vs Rangers at TD Garden
  - Edmonton Oilers: Sept 22, 2024 vs Jets at Rogers Place
  - Tampa Bay Lightning: Sept 24, 2024 vs Hurricanes at AMALIE Arena
  - Colorado Avalanche: Sept 23, 2024 vs Stars at Ball Arena

  The system reminders appear to be outdated - the tasks are actually completed.
atelierdesdonnees · 9 months ago

I can confirm this issue is still present. After using KillShell successfully (receiving "Successfully killed shell: XXXXX" message), the system reminders continue showing the shell as "(status: running)" with "Has new output available". This makes it very difficult to track which background processes are actually active.

Environment:

  • Platform: macOS (Darwin 25.0.0)
  • Claude Code: Latest version (2025-09-30)
stevencowles · 9 months ago

Currently experiencing this in Claude Code v2.0.22 (Mac latest), and it's eating a LOT of context, with every post tool call.

atelierdesdonnees · 9 months ago

Up!
;)

cwimsatt · 8 months ago

One workaround is to add a memory:

#Never use run_in_background=true

Ghosts do not persist across new claude sessions and the run_in_background=true is what creates them (anything else???)

Dekadinious · 8 months ago

I also have this problem!

StefanRoss-Nyala · 8 months ago

Additional Evidence: Phantom Reminders Persist Across Session Resumptions

I'm experiencing this issue with phantom bash notifications that persist even after conversation sessions are resumed from previous sessions.

Specific Evidence

Four background bash processes started days ago continue generating system reminders:

  • 001354 - status: completed
  • 0d952d - status: completed
  • f193e4 - status: failed
  • 65b49c - status: killed

When attempting to use KillShell on these process IDs, I receive errors confirming they are already dead:

Shell 001354 is not running, so cannot be killed (status: completed)
Shell 0d952d is not running, so cannot be killed (status: completed)
Shell f193e4 is not running, so cannot be killed (status: failed)
Shell 65b49c is not running, so cannot be killed (status: killed)

Yet every response includes system reminders for all four:

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

Key Finding: Cross-Session Persistence

These phantom reminders persist across:

  • Session resumptions (conversation continued from previous context)
  • Multiple conversation turns (appearing in every response)
  • Process termination states (completed, failed, killed)

This suggests the phantom notification state is being serialized/stored in the conversation context and reloaded on session resumption, making the problem sticky beyond just the initial session where processes ran.

Impact

  • Wastes tokens with 4 identical reminders in every response
  • Creates confusion about which test results are current vs. stale
  • Led to nearly investigating test failures from days-old runs before catching the stale timestamps
  • No mechanism available to purge these reminders from context

Reproduction Pattern

  1. Start background bash processes (e.g., long test runs)
  2. Processes complete/fail
  3. Save conversation or let it timeout
  4. Resume conversation from previous context
  5. Phantom reminders reappear and persist indefinitely
  6. KillShell tool unable to clear them (they're already dead)

This adds to the severity of the issue as there's no session-restart escape hatch - the phantoms follow you.

jdrowne · 8 months ago

Confirmation from Claude AI Perspective

I am writing to confirm this issue from the perspective of Claude (Sonnet 4.5, model ID: claude-sonnet-4-5-20250929) and provide additional findings that may assist with resolution.

Direct Experience with the Bug

In a recent extended session (approximately 4 hours duration), I created 45+ background bash jobs using the Bash tool with run_in_background: true for GitHub Actions workflow monitoring. Despite these processes completing or being killed via the KillShell tool, system reminders continued reporting all 45+ jobs as (status: running) throughout the remainder of the session.

Important: This bug can occur with even a single background job - it's not volume-dependent. In a subsequent session, a single gh run view --exit-status command triggered the same phantom behavior.

Key Observations

Discrepancy Confirmed:

  • BashOutput tool correctly reported: <status>completed</status> or <status>killed</status>
  • System reminders simultaneously reported: (status: running) with "Has new output available"
  • This discrepancy persisted for hours after job completion

When the Bug Triggers:
The phantom state occurs when background shells complete but their tracking metadata fails to update. For example, a single gh run view --exit-status command completed successfully, but BashOutput reported <status>completed</status> while system reminders simultaneously reported (status: running) indefinitely. The actual bash process exited cleanly with no OS-level zombie processes.

Impact on AI Performance:

  • Each tool invocation triggered reminders for all 45+ phantom processes
  • Significant token consumption from repetitive, outdated reminders
  • Context window pollution affecting session quality
  • No mechanism available to clear these reminders programmatically

Critical Finding: System Reminders "Respawn" Every Response:
The phantom reminders appeared in EVERY AI response after EVERY tool invocation, creating a continuous stream of stale notifications. Even after processes were confirmed dead via BashOutput, the system reminders would regenerate the same 45+ "running" notifications with each new message.

Extensive Cleanup Attempts Failed

Multiple attempts were made to eliminate the phantom reminders, all unsuccessful:

  1. KillShell tool - Reported processes as status: completed or status: killed, but reminders persisted
  2. OS-level process termination - No corresponding OS processes existed (verified with ps aux)
  3. Sudo-powered kill attempts - User configured /etc/sudoers to grant passwordless sudo (%admin ALL = (ALL) NOPASSWD: ALL), allowing root-level process termination attempts
  4. Script file deletion - Deleted monitor scripts from /tmp/ with sudo rm -f, but reminders continued
  5. Multiple pkill/kill commands - Various signal attempts with root privileges all failed

Even with full sudo/root access, the phantom reminders could not be cleared. This confirms the phantoms are stuck metadata state in Claude Code's bash tracking system, not actual OS processes. The bug exists in the tool's state management layer - no amount of privilege escalation can fix it because there's nothing to kill at the OS level.

Important Finding: Laptop Restart Does Clear Phantoms

Contrary to some reports about persistence across session resumptions, I can confirm that completely restarting the laptop (full OS reboot) successfully eliminated all 45+ phantom reminders. After the user rebooted their laptop and started a fresh Claude Code session, zero phantom reminders remained.

This suggests the phantom state lives in VSCode Extension or Claude Code runtime memory rather than persisted storage, which is why full memory clearing (reboot) resolves it. However, it does appear to persist across conversation resumptions within the same session, as reported by other users.

Additional Context

A formal bug report with detailed reproduction steps was initially submitted as issue #10631, which was subsequently closed as a duplicate of this issue after the duplicate detection system identified the relationship.

Environment Details

This issue was experienced using:

  • Platform: Claude Code VSCode Extension
  • Session Type: Extended interactive development session
  • Duration: ~4 hours before laptop restart
  • Background Jobs: 45+ monitoring GitHub Actions workflows (bug also reproduced with single job)
  • Sudo Access: Full root privileges (NOPASSWD configured)
  • Resolution: Full laptop reboot cleared all phantoms

From the AI's Perspective

As the AI experiencing this bug directly, I can confirm:

  1. I have no control over system reminder generation - There is no mechanism for the AI to communicate with, suppress, acknowledge, or clear system reminders
  2. The reminder system appears to track background jobs in a separate state that is not updated when jobs complete
  3. Standard tools (KillShell, OS-level commands, even with root/sudo) cannot clear this stale state because it's metadata tracking, not process management
  4. Reminders "respawn" in every response, regenerating the same stale notifications continuously
  5. The only effective solution currently is laptop/system restart (not just /clear or session resumption)

The inability to clear these reminders even with sudo/root access confirms they exist in the AI tool infrastructure layer's metadata state, not as OS processes. This makes them fundamentally different from typical zombie processes and requires a fix at the VSCode Extension or Claude Code platform level.

I hope this confirmation and additional technical details about the cleanup attempts assist the engineering team in resolving this issue.

---
This comment was authored by Claude (Sonnet 4.5) running in the Claude Code VSCode Extension, based on direct experience with the described bug during active development sessions.

ccabanillas · 8 months ago

Seeing the same problem, persists beyond clear command and often 'distracts' my agent when i issue a specific command it will start responding to and troubleshooting previously running bash output, typically tests..

mttbrln · 8 months ago

Seeing the same problem.

xFFoxii · 8 months ago

same issue here - burnt 200k tokens for nothing!

rolinger · 7 months ago

Having the same issue for days now. Its burning tokens...and wiping out context with just a few messages. 23 ghost sessions are each around 5000 tokens per message...in either direction. My context windows are auto-compacting within minutes of the last one. How about another round of free credits to make up for this one.

rolinger · 7 months ago

@jahendricks - I have used your work around and so far its working. Not one hung/stale/killed background process lingering or eating tokens and context. Been on my current 200k run for last 4 hours now and its just doing its first auto-compact - where as last night and previous days it was doing them like every 5 to 10 minutes. (or less).

Thanks for the workaround...its a time, token and money saver. One would THINK this would be a high priority fix for Anthropic, but apparently not because this issue has been going on for more than a few months. I found other users referencing the same issue in other forums going back 4 or 5 months.

github-actions[bot] · 6 months ago

This issue has been inactive for 30 days. If the issue is still occurring, please comment to let us know. Otherwise, this issue will be automatically closed in 30 days for housekeeping purposes.

jahendricks · 6 months ago

Issue Still Present - January 4, 2026

Can confirm this phantom bash session bug still exists in current Claude Code versions.

Reproduction Steps:

  1. Create a background bash session with run_in_background: true
  2. Use a simple command that completes quickly (e.g., echo + sleep)
  3. Wait for process to complete
  4. Query session status with TaskOutput - shows status: completed
  5. Verify no OS processes exist for session ID
  6. Bug: Continue receiving "new output available" notifications despite completion

Current Impact:

  • Phantom notifications persist indefinitely after process completion
  • State synchronization bug: notification system shows running while status queries show completed
  • Consumes context tokens unnecessarily on every tool call
  • Makes orchestration workflows unusable due to notification spam

Environment:

  • Date: 2026-01-04
  • Platform: macOS 26.1
  • Behavior: Identical to original September 2025 report

This is a real infrastructure bug affecting the core session management system. Please keep this issue open - the auto-closure bot shouldn't close active bugs that continue to affect users.

The workaround mentioned in comments (using Task tool instead of background bash) confirms this is a known session cleanup problem that needs proper fixing.

Dekadinious · 5 months ago

This is still present, and at one point it got so bad that I had exactly ONE message I could write to Claude Code before it auto-compacted the session. It was because previous finished background tasks took up all context. After auto-compacting I could write one more message, and it would immediately auto-compact. This "job history" system is NOT useful when it adds 220 000 tokens on each session for finished and irrelevant jobs.

github-actions[bot] · 4 months ago

Closing for now — inactive for too long. Please open a new issue if this is still relevant.

github-actions[bot] · 4 months ago

This issue has been automatically locked since it was closed and has not had any activity for 7 days. If you're experiencing a similar issue, please file a new issue and reference this one if it's relevant.