Fix truncation of bash output (#28374)

Release Notes:

- Fixed a regression that caused the bash tool to not include all of the
output.

---------

Co-authored-by: Agus Zubiaga <hi@aguz.me>
This commit is contained in:
Antonio Scandurra 2025-04-08 17:41:20 -06:00 committed by GitHub
parent 64cea2f1f1
commit d0632a5332
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -156,7 +156,21 @@ impl Tool for BashTool {
// Read one more byte to determine whether the output was truncated // Read one more byte to determine whether the output was truncated
let mut buffer = vec![0; LIMIT + 1]; let mut buffer = vec![0; LIMIT + 1];
let bytes_read = reader.read(&mut buffer).await?; let mut bytes_read = 0;
// Read until we reach the limit
loop {
let read = reader.read(&mut buffer).await?;
if read == 0 {
break;
}
bytes_read += read;
if bytes_read > LIMIT {
bytes_read = LIMIT + 1;
break;
}
}
// Repeatedly fill the output reader's buffer without copying it. // Repeatedly fill the output reader's buffer without copying it.
loop { loop {