Table of Contents

Class MemoryEvictedEventArgs

Namespace
LMKit.Agents.Memory
Assembly
LM-Kit.NET.dll

Provides data for the MemoryEvicted event, which fires before a memory entry is removed due to capacity enforcement.

public sealed class MemoryEvictedEventArgs : EventArgs
Inheritance
MemoryEvictedEventArgs
Inherited Members

Examples

Example: Logging and selectively protecting memories from eviction

using LMKit.Agents;
using LMKit.Agents.Memory;

memory.MemoryEvicted += (sender, e) =>
{
    Console.WriteLine($"Evicting: {e.Text} (created: {e.CreatedAt})");

    // Protect memories from a specific data source
    if (e.DataSourceIdentifier == "critical_knowledge")
    {
        e.Cancel = true;
    }
};

Remarks

This event fires once for each memory entry that is about to be evicted. The application can inspect the entry's content and metadata, and optionally cancel the eviction by setting Cancel to true. When an eviction is cancelled, the next candidate in the eviction order is evaluated instead.

Properties

Cancel

Gets or sets a value indicating whether this eviction should be cancelled.

CreatedAt

Gets the creation timestamp of the evicted memory in ISO 8601 format. May be null if the memory was created before timestamp tracking was added.

DataSourceIdentifier

Gets the identifier of the data source containing the evicted section.

SectionIdentifier

Gets the identifier of the section being evicted.

Text

Gets the text payload of the evicted memory entry.