Skip to content

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
NousResearch:mainfrom
vatevstoil:fix/terminal-bash-probe-tree-kill
Open

fix(terminal): tree-kill a hung bash probe on Windows instead of blocking forever in the post-timeout reap#78510
vatevstoil wants to merge 1 commit into
NousResearch:mainfrom
vatevstoil:fix/terminal-bash-probe-tree-kill

Conversation

@vatevstoil

Copy link
Copy Markdown

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 probe bash.exe stayed alive for 7+ minutes and the turn never completed.

Root cause

_bash_starts() used subprocess.run(..., timeout=15). On Windows that construct is not hang-proof:

  • on TimeoutExpired, run() calls Popen.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-less communicate(), whose reader-thread join() blocks until the pipe closes — i.e. forever.

py-spy of the hung process shows exactly that: run → communicate → _communicate → join with the probe bash still alive. Killing the probe's process tree by hand instantly unblocked the turn.

Fix

Replace subprocess.run with an explicit Popen:

  • communicate(timeout=15) as before;
  • on timeout, kill the whole process tree (taskkill /T /F on Windows, kill() elsewhere);
  • reap with a bounded 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

…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)
@alt-glitch alt-glitch added type/bug Something isn't working comp/cli CLI entry point, hermes_cli/, setup wizard tool/terminal Terminal execution and process management backend/local Local shell execution platform/windows Native Windows-specific behavior or breakage P2 Medium — degraded but workaround exists duplicate This issue or pull request already exists sweeper:risk-platform-windows Sweeper risk: may break or behave differently on native Windows labels Aug 4, 2026
@alt-glitch

Copy link
Copy Markdown
Collaborator

This was generated by AI during triage.

Duplicate of #69083. Both replace the Windows Git-Bash startup probe's unbounded post-timeout cleanup with bounded tree-kill and reap; #69083 is the earlier, broader implementation with retained-stdin coverage.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backend/local Local shell execution comp/cli CLI entry point, hermes_cli/, setup wizard duplicate This issue or pull request already exists P2 Medium — degraded but workaround exists platform/windows Native Windows-specific behavior or breakage sweeper:risk-platform-windows Sweeper risk: may break or behave differently on native Windows tool/terminal Terminal execution and process management type/bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants