use thiserror::Error;
#[derive(Debug, Clone)]
pub struct ToolArgIssue {
pub pointer: String,
pub message: String,
}
#[derive(Debug, Clone, Error)]
#[error("tool args invalid: {} issue(s)", issues.len())]
pub struct ToolArgError {
pub issues: Vec<ToolArgIssue>,
}
impl ToolArgError {
pub fn for_llm(&self) -> String {
let mut s = String::from("Tool call rejected. Fix and try again:\n");
for i in &self.issues {
s.push_str(" - ");
if !i.pointer.is_empty() {
s.push_str(&i.pointer);
s.push_str(": ");
}
s.push_str(&i.message);
s.push('\n');
}
s.trim_end().to_string()
}
}