pub struct ToolInputMinimizer { /* private fields */ }Expand description
Strips sensitive or unnecessary content from tool call arguments.
Before a tool call is executed, the minimizer removes:
- System prompt fragments (e.g., “You are a …”, “Your instructions are …”)
- Prompt injection attempts embedded in tool arguments
- Excessive whitespace and padding
- PII (email, phone, SSN patterns) when configured
- Content exceeding the maximum input length
Implementations§
Source§impl ToolInputMinimizer
impl ToolInputMinimizer
Sourcepub fn new() -> Self
pub fn new() -> Self
Create a new minimizer with default patterns and settings.
Default maximum input length is 10,000 characters. PII stripping is enabled by default.
Sourcepub fn with_max_input_length(self, max: usize) -> Self
pub fn with_max_input_length(self, max: usize) -> Self
Set the maximum input length (in characters).
Sourcepub fn with_strip_pii(self, strip: bool) -> Self
pub fn with_strip_pii(self, strip: bool) -> Self
Set whether PII should be stripped from tool inputs.
Sourcepub fn minimize(
&self,
input: &str,
_tool_context: &ToolContext,
) -> MinimizeResult
pub fn minimize( &self, input: &str, _tool_context: &ToolContext, ) -> MinimizeResult
Minimize tool input by stripping sensitive and unnecessary content.
Returns a MinimizeResult containing the cleaned text and metadata
about what was removed.
Trait Implementations§
Source§impl Debug for ToolInputMinimizer
impl Debug for ToolInputMinimizer
Auto Trait Implementations§
impl Freeze for ToolInputMinimizer
impl RefUnwindSafe for ToolInputMinimizer
impl Send for ToolInputMinimizer
impl Sync for ToolInputMinimizer
impl Unpin for ToolInputMinimizer
impl UnsafeUnpin for ToolInputMinimizer
impl UnwindSafe for ToolInputMinimizer
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