pub fn session_stats(messages: &[AgentMessage]) -> SessionStatsExpand description
Fold a conversation into a SessionStats.
Contract:
turns/token sums iterate everyAgentMessage::Assistant { usage: Some(u), .. }; a missingcache_read_tokens/cache_write_tokenscounts as 0.toolstallies everyContentBlock::ToolCall { name, .. }across Assistant messages (independently of whether a matching ToolResult exists), then sorts by count desc, name asc.last_input_tokensis theinput_tokensof the last Assistant withSome(usage).- Empty input ⇒
SessionStats::default().