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

Function truncate_for_summary

atomic-agent/src/provenance/classify.rs:768–779  ·  view source on GitHub ↗

Truncate a string for summary display, adding "..." if truncated.

(s: &str, max_len: usize)

Source from the content-addressed store, hash-verified

766
767/// Truncate a string for summary display, adding "..." if truncated.
768fn truncate_for_summary(s: &str, max_len: usize) -> String {
769 // Take first line only
770 let first_line = s.lines().next().unwrap_or(s);
771 let trimmed = first_line.trim();
772
773 if trimmed.len() <= max_len {
774 trimmed.to_string()
775 } else {
776 let truncated: String = trimmed.chars().take(max_len.saturating_sub(3)).collect();
777 format!("{}...", truncated)
778 }
779}
780
781// =============================================================================
782// Tests

Callers 4

summarize_tool_callFunction · 0.85
summarize_explorationFunction · 0.85
summarize_executionFunction · 0.85

Calls 3

nextMethod · 0.45
linesMethod · 0.45
lenMethod · 0.45

Tested by 1