ssm_tail_boundary

Function ssm_tail_boundary 

Source
pub fn ssm_tail_boundary(
    total_tokens: usize,
    block_size: usize,
) -> Option<usize>
Expand description

Last paged-KV block boundary strictly below total_tokens.

A warm multi-turn hit can never match past this point: the chat template’s generation-prompt suffix (assistant header, and the empty <think></think> block emitted when thinking is disabled) is not reproduced when the next turn re-renders the completed assistant message, so the longest common prefix diverges inside the prompt’s final block. RadixTree::walk then floors matched_tokens to this boundary. Placing an SSM snapshot here makes the next turn’s restore exact (zero recurrence replay); without it the lookup falls back to the coarse --ssm-checkpoint-interval grid.

Returns None when the prompt is too short to have such a boundary.