fuse_snapshots

Function fuse_snapshots 

Source
pub fn fuse_snapshots(
    live: &PreparedMemorySnapshot,
    prepared: &PreparedMemorySnapshot,
    max_memories: usize,
    max_tokens: usize,
    now: DateTime<Utc>,
) -> PreparedMemorySnapshot
Expand description

Merge a live search with a prepared snapshot, ranked by RRF.

Serving one or the other is a choice the engine used to make with PreparedMemorySnapshot::satisfies, and it made it badly: measured against snapshots that already held the answer, satisfies refused 65 of 93 paraphrased questions, discarding a correct snapshot in favour of a lexical search that could not find one. Neither ranking is reliably better, so neither gets to win outright.

The same 1/(60 + rank) the retriever already fuses lexical rankings with, so a fact both agree on rises and a fact only one found still gets a place. A stale prepared snapshot contributes nothing — it is a snapshot of a conversation that has moved on. max_tokens is a hard cap, not a target. Both inputs were assembled under it independently, which does not make their union compliant: two single-fact snapshots of 400 tokens each fuse to 800 under a 500 cap. The count limit alone cannot catch that — it is a limit on a different quantity — so the budget is reapplied here, the same way ContextAssembler applies it, and for the same reason: whatever this returns is what fills the model’s context.