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

Function truncate_for_summary

atomic-agent/src/provenance/classify.rs:609–620  ·  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

607
608/// Truncate a string for summary display, adding "..." if truncated.
609fn truncate_for_summary(s: &str, max_len: usize) -> String {
610 // Take first line only
611 let first_line = s.lines().next().unwrap_or(s);
612 let trimmed = first_line.trim();
613
614 if trimmed.len() <= max_len {
615 trimmed.to_string()
616 } else {
617 let truncated: String = trimmed.chars().take(max_len.saturating_sub(3)).collect();
618 format!("{}...", truncated)
619 }
620}
621
622// =============================================================================
623// 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