Skip to main content

plan_drop_oldest

Function plan_drop_oldest 

Source
pub fn plan_drop_oldest(
    messages: &[Message],
    total_tokens: u32,
    target_tokens: u32,
    keep: usize,
    engine: &ContextTokenEngine,
) -> (usize, u32)
Expand description

Pure selection (W1-1 collapse): how many of the oldest history messages to drop to bring the partition under target_tokens, never crossing the preserve-recent floor (keep messages). Returns (count, tokens_saved); the executor just drains count from the front. This is the decision the cache-aware planner reuses to “batch one big drop to target” rather than re-deriving the count inside the compactor.