Calculate aggregate statistics for a collection of runs
Detect common error patterns across multiple error messages Finds the longest common substring that appears in all errors
Estimate cost from token count (using average pricing) Note: This uses an average rate and may not reflect actual costs
Estimate token count from string (rough approximation) Uses the common rule of ~4 characters per token
Format duration in human-readable format
Get truncation rules based on detail level and max tokens
Suggest fixes based on error pattern and failed step context Analyzes error messages and provides actionable debugging suggestions
Truncate field with smart preview (first + last chars) Shows beginning and end of content with truncation indicator
Utility class for analyzing agent run data and applying smart truncation