Skip to main content

repack_decision

Function repack_decision 

Source
pub fn repack_decision(messages: &[Value], cached: usize) -> bool
Expand description

Decide whether to repack the (predicted-cold) cached prefix for THIS request, recording this request as the conversation’s latest touch.

Returns true when the conversation is already in the sticky repacking state (a prior turn went cold — keep the compressed prefix stable, #499) or when a fresh cold gap is detected: a client-cached prefix exists (cached > 0), a prior touch exists (so the idle gap is measurable), and the idle gap exceeds TTL × SAFETY_MARGIN and the absolute floor. The caller owns the opt-in gate; this is only ever called when the operator enabled it, so updating the last-touch baseline here is the intended side effect for the next request.