pub enum RecallPolicy {
Importance,
Hybrid {
recency_weight: f32,
frequency_weight: f32,
},
}Expand description
Controls how memories are scored and ranked during recall.
§Interaction with DecayPolicy
When both a DecayPolicy and a RecallPolicy are configured, decay is
applied before scoring. This means that for RecallPolicy::Importance,
an old high-importance memory may rank lower than a fresh low-importance
memory after decay has reduced its score.
For RecallPolicy::Hybrid, the recency_weight term already captures
temporal distance; combining it with a DecayPolicy therefore applies a
double time penalty — set one or the other, not both, unless the double
penalty is intentional.
§Score Calculation Example
Given two memories, each with importance = 0.5:
- Memory A:
recall_count = 0, inserted 1 hour ago - Memory B:
recall_count = 10, inserted 10 hours ago
With recency_weight = 1.0 and frequency_weight = 0.1:
- Score A =
0.5 + 1.0 × 1.0 + 0.1 × 0=1.5(recency wins) - Score B =
0.5 + 1.0 × (−10.0) + 0.1 × 10=−8.5(old → ranked lower)
Note: the recency term uses negative hours-since-creation so older items score lower.
Variants§
Importance
Rank purely by importance score (default).
Hybrid
Hybrid score: blends importance, recency, and recall frequency.
score = importance + recency_score * recency_weight + frequency_score * frequency_weight
where recency_score = exp(-age_hours / 24.0) and
frequency_score = recall_count / (max_recall_count + 1) (normalized).
Trait Implementations§
Source§impl Clone for RecallPolicy
impl Clone for RecallPolicy
Source§fn clone(&self) -> RecallPolicy
fn clone(&self) -> RecallPolicy
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more