Bash tool runs commands in background despite run_in_background not being set
Resolved 💬 2 comments Opened Mar 6, 2026 by KikeTorillo Closed Apr 4, 2026
Description
The Bash tool intermittently runs commands in background (returning a task_id and writing output to a temp file) even when run_in_background is not set to true in the tool call.
This forces the agent to poll with TaskOutput, adding significant latency to simple commands that complete in seconds.
Reproduction
- Call the Bash tool with a simple command like
poetry run pytest tests/ -qwithout settingrun_in_background - Instead of returning output directly, it returns:
````
Command running in background with ID: bt2kelt7i. Output is being written to: /tmp/claude-1000/.../tasks/bt2kelt7i.output
- Subsequent
TaskOutputcalls with 30s-120s timeouts all returnretrieval_status: timeouteven though the command finishes in ~4 seconds - The output file remains empty or takes very long to become readable
Expected behavior
Commands should run in foreground and return output directly when run_in_background is not explicitly set to true.
Observed behavior
- Commands are silently promoted to background execution
TaskOutputpolling adds minutes of latency to a 4-second test suite- Multiple
TaskOutputcalls with increasing timeouts (30s, 60s, 120s) all timed out before the output was available - The output eventually appeared but only after significant delay
Environment
- Claude Code (CLI)
- Model: claude-opus-4-6
- OS: Linux 6.17.0-14-generic (Ubuntu)
- Shell: bash
- The Bash permission
"Bash(poetry run pytest:*)"and"Bash(poetry run:*)"are both in the allow list
Workaround
None reliable. The behavior is intermittent — the same commands run in foreground in other sessions.
This issue has 2 comments on GitHub. Read the full discussion on GitHub ↗