[BUG] Deduplication for Concurrent Background Bash Tasks since 2.1.112 to 2.1.114

Resolved 💬 1 comment Opened Apr 18, 2026 by luarworld Closed May 25, 2026

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?

When run_in_background: true is used on the Bash tool, Claude Code spawns a new background instance every time the same (or nearly identical) command is invoked, even if a prior instance is still running. No warning or deduplication check is performed.

What Should Happen?

Claude Code should:

  • Detect that a background task with an identical or near-identical command is already running
  • Either warn the model before launching a duplicate, or
  • Return the existing task ID instead of spawning a new instance
  • Surface this information clearly in the Bash tool response

Error Messages/Logs

- Each invocation silently spawns a new background process
- The Bash tool returns `"Command running in background with ID: XXX"` without indicating whether a prior run is still active
- The model receives no signal that the command is already in flight
- Result: the same operation runs N times in parallel, wasting resources and creating race conditions

Steps to Reproduce

  1. Define a long-running Bash command (example a 16-minute test suite)
  2. Call the Bash tool with run_in_background: true
  3. Immediately call the identical command again before the first completes
  4. Observe that both commands spawn as separate background processes
  5. Repeat 3-4 more times within a short window (e.g., 13 minutes)
  6. Result: 5+ identical processes run in parallel, all unaware of each other

this started happening on Sonnet and Opus since version 2.1.112. Upgraded to 2.1.114 and same outcome. Happens on multiple servers I have running development test suites on. This worked on previous versions. I now have to halt all work because of loops and constant token use.

Claude Model

Sonnet (default)

Is this a regression?

Yes, this worked in a previous version

Last Working Version

any version before 2.1.112

Claude Code Version

2.1.114

Platform

Anthropic API

Operating System

Ubuntu/Debian Linux

Terminal/Shell

Non-interactive/CI environment

Additional Information

Impact on workflow is

  • Unintended resource contention and multiplied execution time
  • No visibility into duplicate work
  • Particularly problematic for long-running operations (CI/CD, data processing, tests)
  • Model may believe it has started one background job when in fact multiple are running

Implement a better deduplication mechanism:

  1. Hash background tasks by command (exact or normalized)
  2. Check if an identical task is already running before spawning
  3. Return the existing task ID if a duplicate is detected, with a notice like "Task already running with ID: YYY"
  4. Alternatively, add an optional --deduplicate flag to opt into this behavior
  5. Document the behavior clearly in the Bash tool specification

View original on GitHub ↗

This issue has 1 comment on GitHub. Read the full discussion on GitHub ↗