Enum MemoryEvictionPolicy
Specifies the strategy used to select which memories to evict when the AgentMemory reaches its MaxMemoryEntries limit.
public enum MemoryEvictionPolicy
Fields
OldestFirst = 0Evicts the oldest memories first, based on their
created_attimestamp. This is the default policy.LowestImportanceFirst = 1Evicts memories with the lowest importance level first. When multiple memories share the same importance, the oldest is evicted first.
OldestLowestImportanceFirst = 2Combined policy: evicts the oldest memories first, using importance as a tiebreaker. Among memories with the same creation time, those with lower importance are evicted first.
Examples
Example: Configuring an eviction policy
using LMKit.Agents;
using LMKit.Agents.Memory;
using LMKit.Model;
using var embeddingModel = new LM("path/to/embedding-model.gguf");
var memory = new AgentMemory(embeddingModel);
// Allow up to 200 memory entries; evict the least important first
memory.MaxMemoryEntries = 200;
memory.EvictionPolicy = MemoryEvictionPolicy.LowestImportanceFirst;
Remarks
Eviction policies determine the order in which memories are removed to make room for new ones. The policy is applied after a new memory is stored and the total entry count exceeds MaxMemoryEntries.
Each policy uses the created_at timestamp and/or the importance metadata
stored on each memory section to determine eviction priority.