Property MaxMemoryEntries
MaxMemoryEntries
Gets or sets the maximum number of memory entries (sections) allowed globally across all data sources.
public int MaxMemoryEntries { get; set; }
Property Value
- int
A non-negative integer.
0means unlimited (default).
Examples
Example: Limiting memory to 200 entries
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);
memory.MaxMemoryEntries = 200;
memory.EvictionPolicy = MemoryEvictionPolicy.LowestImportanceFirst;
Remarks
When this limit is reached and a new memory is saved, the system evicts entries according to EvictionPolicy until the count is within the limit. Eviction happens after the new memory is stored, so the new entry is never evicted.
If capacity is reduced below the current EntryCount, excess entries are evicted on the next call to SaveInformationAsync(string, string, string, MemoryType, MetadataCollection, CancellationToken).