[BUG] Deduplication for Concurrent Background Bash Tasks since 2.1.112 to 2.1.114
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
- Define a long-running Bash command (example a 16-minute test suite)
- Call the Bash tool with
run_in_background: true - Immediately call the identical command again before the first completes
- Observe that both commands spawn as separate background processes
- Repeat 3-4 more times within a short window (e.g., 13 minutes)
- 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:
- Hash background tasks by command (exact or normalized)
- Check if an identical task is already running before spawning
- Return the existing task ID if a duplicate is detected, with a notice like
"Task already running with ID: YYY" - Alternatively, add an optional
--deduplicateflag to opt into this behavior - Document the behavior clearly in the Bash tool specification
This issue has 1 comment on GitHub. Read the full discussion on GitHub ↗