Function trim_to_recent_turns
pub fn trim_to_recent_turns(
history: Vec<ChatMessage>,
budget_tokens: usize,
) -> TrimResultExpand description
Drop oldest whole turns until the history fits budget_tokens, always
keeping leading system messages and at least the most recent whole turn.
When budget_tokens is zero the history is returned untouched.