(
&self,
tool_name: &str,
args: &Value,
threshold: u32,
)
| 107 | } |
| 108 | |
| 109 | pub(super) fn duplicate_tool_call( |
| 110 | &self, |
| 111 | tool_name: &str, |
| 112 | args: &Value, |
| 113 | threshold: u32, |
| 114 | ) -> Option<(usize, String)> { |
| 115 | let signature = Self::tool_signature(tool_name, args); |
| 116 | let duplicate_count = self |
| 117 | .recent_tool_signatures |
| 118 | .iter() |
| 119 | .filter(|sig| sig.starts_with(&signature)) |
| 120 | .count(); |
| 121 | |
| 122 | if duplicate_count < threshold as usize { |
| 123 | return None; |
| 124 | } |
| 125 | |
| 126 | Some(( |
| 127 | duplicate_count, |
| 128 | format!( |
| 129 | "Tool '{}' has been called {} times with identical arguments. \ |
| 130 | Aborting to prevent infinite loop. Consider modifying your approach.", |
| 131 | tool_name, duplicate_count |
| 132 | ), |
| 133 | )) |
| 134 | } |
| 135 | |
| 136 | pub(super) fn record_parse_error( |
| 137 | &mut self, |
no outgoing calls