Skip to main content

truncate_to_budget

Function truncate_to_budget 

Source
pub fn truncate_to_budget(messages: &mut Vec<Message>, max_tokens: u64)
Expand description

Truncate messages to fit within a token budget.

Removes oldest messages (preserving the first system/summary message) until the estimated token count is within budget.