Stream bash tool output incrementally instead of buffering until exit - #932
Open
erlinh wants to merge 2 commits into
Open
Stream bash tool output incrementally instead of buffering until exit#932erlinh wants to merge 2 commits into
erlinh wants to merge 2 commits into
Conversation
Bash.run() previously called proc.communicate(), which blocks until the process exits and only then yields output. Long-running commands (builds, test suites, dev servers) therefore showed nothing in the UI until they finished. Now stdout/stderr are drained incrementally, emitting a live-updating ToolStreamEvent preview (deduped, single line, <=200 chars) as new output arrives, while preserving the exact same timeout, truncation, and error-message behavior for the final result.
Ruff flagged run() for exceeding branch/statement/local limits, so the preview dedup loop and reader settling move into module-level helpers. Settling now cancels readers still blocked on a live pipe instead of awaiting them, since an external cancellation would otherwise hang until the process exited on its own. Also hoists the test's function-local imports to module level and applies ruff formatting.
erlinh
marked this pull request as ready for review
July 22, 2026 20:27
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.
Summary
Bash.run()usedproc.communicate(), so no output was visible untila command finished — long-running commands (builds, tests, dev
servers) looked stuck even though the rest of the UI stayed responsive.
feeding a shared queue, emitting a
ToolStreamEventwith a short,deduped single-line preview whenever new output appears.
max_output_bytestruncation, error message format, return code handling) are
unchanged — the exact raw bytes are still buffered and decoded via
decode_safe(...)exactly as before.Test plan
test_streams_progress_events_for_long_running_commandtotests/tools/test_bash.py, asserting streamed events precede thefinal
BashResultand each is a single line ≤200 chars.tests/tools/test_bash.py,tests/acp/test_bash.py,tests/tools/test_ui_bash_execution.pypass (pre-existing localWindows-only failures around
fcntl/bash-on-PATH are unrelated,confirmed via
git stashagainst unmodifiedmain).truncation still applies, failure message format unchanged.