pub fn collapse_to_budget(
messages: &[Message],
max_tokens: u64,
) -> Option<CollapseResult>Expand description
Collapse the message history to fit within a token budget.
Removes groups of messages from the middle of the conversation, keeping the first message (summary/context) and the most recent messages intact. Groups are removed oldest-first until the budget is met.