diff --git a/crates/bashkit/src/scripted_tool/execute.rs b/crates/bashkit/src/scripted_tool/execute.rs index f5110d0a..adbab937 100644 --- a/crates/bashkit/src/scripted_tool/execute.rs +++ b/crates/bashkit/src/scripted_tool/execute.rs @@ -320,7 +320,7 @@ impl Tool for ScriptedTool { stdout: String::new(), stderr: e.to_string(), exit_code: 1, - error: Some(format!("{:?}", e)), + error: Some(e.to_string()), }, } } @@ -352,7 +352,7 @@ impl Tool for ScriptedTool { stdout: String::new(), stderr: e.to_string(), exit_code: 1, - error: Some(format!("{:?}", e)), + error: Some(e.to_string()), }, }; @@ -452,4 +452,31 @@ mod tests { usage_from_schema(&serde_json::json!({"type": "object", "properties": {}})).is_none() ); } + + #[tokio::test] + async fn test_error_uses_display_not_debug() { + use super::ScriptedTool; + use crate::tool::Tool; + use crate::ToolDef; + + let mut tool = ScriptedTool::builder("test") + .short_description("test") + .tool( + ToolDef::new("fail", "Always fails"), + |_args: &super::ToolArgs| Err("service error".to_string()), + ) + .build(); + let req = ToolRequest { + commands: "fail".into(), + timeout_ms: None, + }; + let resp = tool.execute(req).await; + // Error messages use Display format, not Debug, to avoid leaking internals + if let Some(ref err) = resp.error { + assert!( + !err.contains("Execution("), + "error should use Display not Debug: {err}", + ); + } + } }