Property EvictionPolicy
EvictionPolicy
Gets or sets the eviction strategy used when memory capacity is exceeded.
public MemoryEvictionPolicy EvictionPolicy { get; set; }
Property Value
- MemoryEvictionPolicy
Default is OldestFirst.
Examples
Example: Using importance-based eviction
var memory = new AgentMemory(embeddingModel);
memory.MaxMemoryEntries = 100;
memory.EvictionPolicy = MemoryEvictionPolicy.LowestImportanceFirst;
// High-importance memories survive longer than low-importance ones
memory.ExtractionMode = MemoryExtractionMode.LlmBased;
Remarks
The policy determines which memories are removed first when the total entry count exceeds MaxMemoryEntries:
- OldestFirstRemoves the oldest entries first, based on creation timestamp.
- LowestImportanceFirstRemoves Low importance entries before Medium and High. Among entries with the same importance, the oldest is removed first.
- OldestLowestImportanceFirstRemoves the oldest entries first, using importance as a tiebreaker. Among entries with the same creation time, those with lower importance are removed first.