diff --git a/src/safety/mod.rs b/src/safety/mod.rs
index 50167fc0..e9027792 100644
--- a/src/safety/mod.rs
+++ b/src/safety/mod.rs
@@ -164,7 +164,7 @@ impl SafetyLayer {
"\n{}\n",
escape_xml_attr(tool_name),
sanitized,
- escape_xml_content(content)
+ content
)
}
@@ -213,13 +213,6 @@ fn escape_xml_attr(s: &str) -> String {
.replace('>', ">")
}
-/// Escape XML content.
-fn escape_xml_content(s: &str) -> String {
- s.replace('&', "&")
- .replace('<', "<")
- .replace('>', ">")
-}
-
#[cfg(test)]
mod tests {
use super::*;
@@ -235,7 +228,7 @@ mod tests {
let wrapped = safety.wrap_for_llm("test_tool", "Hello ", true);
assert!(wrapped.contains("name=\"test_tool\""));
assert!(wrapped.contains("sanitized=\"true\""));
- assert!(wrapped.contains("Hello <world>"));
+ assert!(wrapped.contains("Hello "));
}
#[test]
diff --git a/tests/support/trace_llm.rs b/tests/support/trace_llm.rs
index e09ee9d9..ba3e5744 100644
--- a/tests/support/trace_llm.rs
+++ b/tests/support/trace_llm.rs
@@ -429,7 +429,7 @@ impl TraceLlm {
}
/// Strip `...\n`
- /// wrapper and unescape XML entities from safety-layer output.
+ /// wrapper from safety-layer output.
fn unwrap_tool_output(content: &str) -> std::borrow::Cow<'_, str> {
let trimmed = content.trim();
if let Some(rest) = trimmed.strip_prefix("") {
let body = inner[..close].trim();
- // Reverse XML escaping applied by safety layer.
- if body.contains("&") || body.contains("<") || body.contains(">") {
- return std::borrow::Cow::Owned(
- body.replace("&", "&")
- .replace("<", "<")
- .replace(">", ">"),
- );
- }
return std::borrow::Cow::Borrowed(body);
}
}