fix: The command succeeded, yet the model keeps calling it repeatedly.

This commit is contained in:
Felix
2026-03-20 18:22:08 +08:00
parent db86ff4ce3
commit 865fd28704
+5 -1
View File
@@ -1549,7 +1549,7 @@ async fn tool_shell_exec(
// Truncate very long outputs to prevent memory issues
let max_output = 100_000;
let stdout_str = if stdout.len() > max_output {
let mut stdout_str = if stdout.len() > max_output {
format!(
"{}...\n[truncated, {} total bytes]",
crate::str_utils::safe_truncate_str(&stdout, max_output),
@@ -1568,6 +1568,10 @@ async fn tool_shell_exec(
stderr.to_string()
};
if exit_code == 0 && stdout_str.is_empty() {
stdout_str = "Command executed successfully".to_string();
}
Ok(format!(
"Exit code: {exit_code}\n\nSTDOUT:\n{stdout_str}\nSTDERR:\n{stderr_str}"
))