Table of Contents

Event BeforeMemoryConsolidated

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

Occurs before a cluster of similar memories is merged into a single consolidated entry.

public event EventHandler<MemoryConsolidationEventArgs> BeforeMemoryConsolidated

Returns

EventHandler<MemoryConsolidationEventArgs>
Occurs before a cluster of similar memories is merged into a single consolidated entry.

Examples

Example: Logging and selectively skipping consolidation

memory.BeforeMemoryConsolidated += (sender, e) =>
{
    Console.WriteLine($"Merging {e.OriginalEntries.Count} entries in {e.DataSourceIdentifier}");
    Console.WriteLine($"  Into: {e.ConsolidatedText}");

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

Remarks

Set Cancel to true to skip the merge for a specific cluster. The original entries are preserved.