MCPcopy Create free account
hub / github.com/AI45Lab/Code / duplicate_tool_call

Method duplicate_tool_call

core/src/agent/execution_state.rs:109–134  ·  view source on GitHub ↗
(
        &self,
        tool_name: &str,
        args: &Value,
        threshold: u32,
    )

Source from the content-addressed store, hash-verified

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,

Calls

no outgoing calls