MCPcopy Create free account
hub / github.com/atomicdotdev/atomic / aggregate_tool_usage

Function aggregate_tool_usage

atomic-agent/src/transcript/condense.rs:233–258  ·  view source on GitHub ↗

Aggregate tool usage from condensed entries.

(entries: &[CondensedEntry])

Source from the content-addressed store, hash-verified

231
232/// Aggregate tool usage from condensed entries.
233pub fn aggregate_tool_usage(entries: &[CondensedEntry]) -> Vec<ToolUseSummary> {
234 let mut tools: HashMap<String, ToolUseSummary> = HashMap::new();
235
236 for entry in entries.iter().filter(|e| e.is_tool()) {
237 let name = entry.tool_name.as_deref().unwrap_or("Unknown");
238
239 let summary = tools
240 .entry(name.to_string())
241 .or_insert_with(|| ToolUseSummary::new(name, 0, Vec::new()));
242
243 summary.invocation_count += 1;
244
245 // Track files affected by file-modifying tools
246 if let Some(detail) = &entry.tool_detail {
247 if matches!(name, "Edit" | "Write" | "MultiEdit" | "NotebookEdit")
248 && !summary.files_affected.contains(detail)
249 {
250 summary.files_affected.push(detail.clone());
251 }
252 }
253 }
254
255 let mut result: Vec<_> = tools.into_values().collect();
256 result.sort_by(|a, b| a.tool_name.cmp(&b.tool_name));
257 result
258}
259
260/// Extract user content from a transcript message value.
261fn extract_user_content(message: &serde_json::Value) -> Option<String> {

Callers 4

newMethod · 0.85

Calls 7

is_toolMethod · 0.80
iterMethod · 0.45
containsMethod · 0.45
pushMethod · 0.45
cloneMethod · 0.45
collectMethod · 0.45
cmpMethod · 0.45