pub fn memory_first_keep_tail(
messages: &[Message],
history_start: usize,
) -> usizeExpand description
Compute how many tail messages to keep when the MemoryFirst strategy is active.
Always keeps at least 2 messages. Extends the tail as long as the boundary message is
a ToolResult (user message with a ToolResult part) to avoid splitting a tool-call
round-trip. Capped at MAX_KEEP_TAIL_SCAN to prevent O(N) scans on long sessions.
history_start is the index of the first non-system message (typically 1).