Property TimeDecayHalfLife
TimeDecayHalfLife
Gets or sets the half-life for time-decay scoring during memory retrieval.
public TimeSpan TimeDecayHalfLife { get; set; }
Property Value
- TimeSpan
A TimeSpan representing the period after which a memory's retrieval score is halved. Zero disables time-decay (default).
Examples
Example: Applying 30-day half-life decay
var memory = new AgentMemory(embeddingModel);
memory.TimeDecayHalfLife = TimeSpan.FromDays(30);
// A 30-day-old memory scores 50% of its original similarity.
// A 60-day-old memory scores 25%.
// A 90-day-old memory scores 12.5%.
Remarks
When enabled, the similarity score of each retrieved memory is multiplied by an
exponential decay factor based on its age: score * e^(-ln(2) / halfLife * age).
This makes recent memories surface more prominently than older ones, even if both are
equally relevant by content.
Typical values:
TimeSpan.FromDays(30): gentle decay, suitable for long-term knowledge basesTimeSpan.FromDays(7): moderate decay, suitable for active project contextsTimeSpan.FromDays(1): aggressive decay, suitable for ephemeral session data
Time-decay requires a created_at timestamp on each memory entry. Entries without
a timestamp receive no decay penalty (treated as brand new).