From 865fd28704c79625d5bc9c9ccdd6d3fb6df962b3 Mon Sep 17 00:00:00 2001 From: Felix <307253927@qq.com> Date: Fri, 20 Mar 2026 18:21:06 +0800 Subject: [PATCH] fix: The command succeeded, yet the model keeps calling it repeatedly. --- crates/openfang-runtime/src/tool_runner.rs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/crates/openfang-runtime/src/tool_runner.rs b/crates/openfang-runtime/src/tool_runner.rs index 0e185359..ac8e3df2 100644 --- a/crates/openfang-runtime/src/tool_runner.rs +++ b/crates/openfang-runtime/src/tool_runner.rs @@ -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}" ))