Background task counter not decremented after TaskOutput acknowledgment or session compaction

Resolved 💬 6 comments Opened Feb 3, 2026 by seaberger Closed Mar 10, 2026

Bug Description

The status bar shows "3 background tasks" even after:

  1. All background tasks have completed (confirmed via task-notifications)
  2. TaskOutput was called on completed tasks (returned status: completed)
  3. Task output files were cleaned up

The counter persists and cannot be cleared.

Steps to Reproduce

  1. Start background tasks using run_in_background: true on Bash tool
  2. Wait for tasks to complete (receive task-notification with status: completed)
  3. Call TaskOutput on the completed task IDs - returns success with status: completed
  4. Observe status bar still shows the same number of background tasks

Additionally:

  1. If session runs out of context and gets compacted/summarized
  2. Background task counter persists but task IDs are lost
  3. Orphaned tasks can never be acknowledged

Expected Behavior

  • Calling TaskOutput on a completed task should decrement the background task counter
  • Session compaction should either preserve task IDs or reset the counter

Actual Behavior

  • TaskOutput returns success but counter stays the same
  • After session compaction, tasks become orphaned (counter persists, task IDs lost)

Environment

  • Claude Code CLI
  • Model: Opus 4.5
  • Custom statusline enabled (but issue is with Claude Code's internal task tracking, not custom script)

Screenshot

Status bar showing "3 background tasks" after all tasks completed and acknowledged:

  • Tasks bb5c918 and bf41fab both returned status: completed from TaskOutput
  • Third task likely orphaned from pre-compaction session

Workaround

Currently none known except restarting the Claude Code session.

View original on GitHub ↗

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