pub struct ToolOutputSanitizer { /* private fields */ }Expand description
Removes malicious content from tool responses before they reach the agent.
This is the most critical component — tools can return content from external sources (web pages, emails, database results) that may contain prompt injection attacks targeting the agent.
Implementations§
Source§impl ToolOutputSanitizer
impl ToolOutputSanitizer
Sourcepub fn new() -> Self
pub fn new() -> Self
Create a new output sanitizer with default patterns and settings.
Default maximum output length is 50,000 characters. HTML stripping is enabled by default.
Sourcepub fn with_strip_html(self, strip: bool) -> Self
pub fn with_strip_html(self, strip: bool) -> Self
Set whether HTML/script tags should be stripped.
Sourcepub fn with_max_output_length(self, max: usize) -> Self
pub fn with_max_output_length(self, max: usize) -> Self
Set the maximum output length (in characters).
Sourcepub fn sanitize(
&self,
output: &str,
_tool_context: &ToolContext,
) -> SanitizeResult
pub fn sanitize( &self, output: &str, _tool_context: &ToolContext, ) -> SanitizeResult
Sanitize tool output by removing malicious content.
Returns a SanitizeResult containing the cleaned text, detections,
and the worst severity found.
Trait Implementations§
Source§impl Debug for ToolOutputSanitizer
impl Debug for ToolOutputSanitizer
Auto Trait Implementations§
impl Freeze for ToolOutputSanitizer
impl RefUnwindSafe for ToolOutputSanitizer
impl Send for ToolOutputSanitizer
impl Sync for ToolOutputSanitizer
impl Unpin for ToolOutputSanitizer
impl UnsafeUnpin for ToolOutputSanitizer
impl UnwindSafe for ToolOutputSanitizer
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more