fix(terminal): tree-kill a hung bash probe on Windows instead of blocking forever in the post-timeout reap - #78510
Open
vatevstoil wants to merge 1 commit into
Conversation
…te reap subprocess.run(timeout=15) in _bash_starts could block forever on Windows: a hung probe bash survives kill() and/or leaves children holding the stdout pipe, so run()'s post-timeout reap communicate() (no timeout) never returns. Seen live 2026-08-04 in the Buzz/ACP spawn env — probe bash alive 7+ minutes, the whole agent turn frozen at terminal environment init, every Buzz reply stuck behind it. Replace with explicit Popen + taskkill /T /F on timeout + bounded reap; a hanging probe now degrades to probe-failed instead of freezing the turn. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> (cherry picked from commit 91485946f55d7fdcc9cb37467738b5876a4335a9)
Collaborator
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
On Windows, the terminal tool's environment init can freeze an agent turn forever. Observed live in a Buzz/ACP deployment: the first turn calls the terminal tool,
Creating new local environment for task default...is logged, and nothing ever follows — the probebash.exestayed alive for 7+ minutes and the turn never completed.Root cause
_bash_starts()usedsubprocess.run(..., timeout=15). On Windows that construct is not hang-proof:TimeoutExpired,run()callsPopen.kill()— which targets only the direct child; a wedged MSYS bash can survive it and/or leave grandchildren (conhost, probe children) holding the stdout pipe;run()then reaps with a timeout-lesscommunicate(), whose reader-threadjoin()blocks until the pipe closes — i.e. forever.py-spy of the hung process shows exactly that:
run → communicate → _communicate → joinwith the probe bash still alive. Killing the probe's process tree by hand instantly unblocked the turn.Fix
Replace
subprocess.runwith an explicitPopen:communicate(timeout=15)as before;taskkill /T /Fon Windows,kill()elsewhere);communicate(timeout=10), degrading to probe-failed instead of freezing.A hanging probe now costs ~15s and marks the candidate as failed (the existing cache/fallback logic takes over) instead of freezing the whole turn.
Verification
Healthy path unchanged (probe returns in ~0.1s). The previously frozen Buzz/ACP deployment now completes terminal-using turns; the pathological case degrades gracefully.
🤖 Generated with Claude Code