pub fn plan_compaction(
ctx: &ContextState,
keep_last: usize,
target_tokens: Option<u64>,
) -> Option<CompactionRequest>Expand description
Decide what to fold. keep_last messages stay verbatim; a fold always
ends before the kept window, never splits an assistant tool-call from its
tool results, and always leaves a User message first in the kept window.
Returns None when there is nothing worth folding (fewer than
keep_last + 2 messages, or no user message to fold up to).