pub enum FormatConstraint {
Json,
JsonWithKeys(Vec<String>),
MaxLines(usize),
MaxChars(usize),
MatchesPattern(Regex),
Custom(Arc<dyn Fn(&str) -> bool + Send + Sync>),
}Expand description
Format constraint for validating tool outputs.
Constraints are applied after sanitization to ensure tool output conforms to expected shapes before being passed to the agent.
Variants§
Json
Output must be valid JSON.
JsonWithKeys(Vec<String>)
Output must be valid JSON containing all specified top-level keys.
MaxLines(usize)
Output must not exceed this many lines.
MaxChars(usize)
Output must not exceed this many characters.
MatchesPattern(Regex)
Output must match this regex pattern.
Custom(Arc<dyn Fn(&str) -> bool + Send + Sync>)
Custom validator function.
Implementations§
Source§impl FormatConstraint
impl FormatConstraint
Sourcepub fn validate(&self, output: &str) -> Result<(), FormatViolation>
pub fn validate(&self, output: &str) -> Result<(), FormatViolation>
Validate the given output against this constraint.
Returns Ok(()) if the output conforms, or a FormatViolation
describing what went wrong.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for FormatConstraint
impl !RefUnwindSafe for FormatConstraint
impl Send for FormatConstraint
impl Sync for FormatConstraint
impl Unpin for FormatConstraint
impl UnsafeUnpin for FormatConstraint
impl !UnwindSafe for FormatConstraint
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