Table of Contents

Method ApplyFilter

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

ApplyFilter()

Applies the user-scope filter to the underlying memory so that retrieval operations only consider this user's data sources.

public void ApplyFilter()

Examples

Example: Applying a user scope before agent execution

var userMemory = new UserScopedMemory(sharedMemory, "alice");
userMemory.ApplyFilter();

// Agent now only retrieves Alice's memories
var agent = Agent.CreateBuilder(chatModel)
    .WithMemory(sharedMemory)
    .Build();

Remarks

Call this method before attaching the SharedMemory to an agent or conversation. The filter is set on the shared Filter property, so only one user scope can be active at a time.

To switch users, call ApplyFilter() on the other user's UserScopedMemory instance, or call ClearFilter() to remove the scope.