Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
51 changes: 51 additions & 0 deletions crates/zeroclaw-runtime/src/agent/loop_.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3730,6 +3730,26 @@ mod tests {
assert_eq!(invocations.load(Ordering::SeqCst), 1);
}

#[tokio::test]
async fn execute_one_tool_normalizes_empty_success_output() {
let observer = NoopObserver;
let tools: Vec<Box<dyn Tool>> = vec![Box::new(EmptySuccessTool)];

let outcome = execute_one_tool(
"empty_success",
serde_json::json!({}),
&tools,
None,
&observer,
None,
)
.await
.expect("empty successful tool output should still execute");

assert!(outcome.success);
assert_eq!(outcome.output, "(no output)");
assert!(outcome.error_reason.is_none());
}
use crate::observability::NoopObserver;
use tempfile::TempDir;
use zeroclaw_api::provider::{ProviderCapabilities, StreamChunk, StreamEvent, StreamOptions};
Expand Down Expand Up @@ -4163,6 +4183,37 @@ mod tests {
}
}

struct EmptySuccessTool;

#[async_trait]
impl Tool for EmptySuccessTool {
fn name(&self) -> &str {
"empty_success"
}

fn description(&self) -> &str {
"Returns success with no stdout"
}

fn parameters_schema(&self) -> serde_json::Value {
serde_json::json!({
"type": "object",
"properties": {}
})
}

async fn execute(
&self,
_args: serde_json::Value,
) -> anyhow::Result<crate::tools::ToolResult> {
Ok(crate::tools::ToolResult {
success: true,
output: String::new(),
error: None,
})
}
}

struct RecordingArgsTool {
name: String,
recorded_args: Arc<Mutex<Vec<serde_json::Value>>>,
Expand Down
7 changes: 6 additions & 1 deletion crates/zeroclaw-runtime/src/agent/tool_execution.rs
Original file line number Diff line number Diff line change
Expand Up @@ -90,8 +90,13 @@ pub async fn execute_one_tool(
success: r.success,
});
if r.success {
let normalized_output = if r.output.is_empty() {
"(no output)"
} else {
&r.output
};
Ok(ToolExecutionOutcome {
output: scrub_credentials(&r.output),
output: scrub_credentials(normalized_output),
success: true,
error_reason: None,
duration,
Expand Down
Loading