Problem
The bash tool (and to a lesser extent exec_command) allocates full command output into bytes.Buffer with no size limit:
// internal/tools/bash.go:127
var stdout bytes.Buffer
var stderr bytes.Buffer
command.Stdout = &stdout
command.Stderr = &stderr
...
output := formatBashOutput(stdout.String(), ...)
Other tools (grep, read_file, web_fetch) use applyOutputBudget + io.LimitReader. Bash does not.
Impact
- Easy OOM or unresponsiveness on large output (cat huge file, gh pr with thousands of comments, find /, verbose tests, etc.).
- Directly caused the "Not enough memory resources..." errors reported during PR review work.
- No backpressure; the process can be killed before the command even finishes.
Suggested fix
- Add a reasonable byte limit (e.g. 10-50 MiB) +
io.LimitReader for stdout/stderr in bash.go (and review exec_command).
- Reuse or extend
applyOutputBudget / max_output_tokens logic.
- Truncate early and surface a clear message + suggestion to narrow the command.
Problem
The
bashtool (and to a lesser extentexec_command) allocates full command output intobytes.Bufferwith no size limit:Other tools (
grep,read_file,web_fetch) useapplyOutputBudget+io.LimitReader. Bash does not.Impact
Suggested fix
io.LimitReaderfor stdout/stderr in bash.go (and review exec_command).applyOutputBudget/max_output_tokenslogic.