Table of Contents

Method RecallAsync

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

RecallAsync(string, int, CancellationToken)

Recalls this user's memories most relevant to a query, ranked by similarity. The scope applies to this call only: nothing on the shared AgentMemory is mutated, so any number of user scopes can recall concurrently.

public Task<IReadOnlyList<RecalledMemory>> RecallAsync(string query, int topK = 0, CancellationToken cancellationToken = default)

Parameters

query string

The question or topic to recall memories for. Cannot be null or empty.

topK int

The maximum number of memories to return. At or below zero (the default), the shared memory's TopK applies.

cancellationToken CancellationToken

A token to monitor for cancellation requests.

Returns

Task<IReadOnlyList<RecalledMemory>>

The user's recalled memories, best match first. Empty when nothing relevant is stored for this user.

Examples

var alice = new UserScopedMemory(sharedMemory, "alice");
var bob = new UserScopedMemory(sharedMemory, "bob");

// Concurrent per-user recalls; neither sees the other's memories.
var aliceFacts = await alice.RecallAsync("what does the user prefer?");
var bobFacts = await bob.RecallAsync("what does the user prefer?");

Exceptions

ArgumentException

Thrown when query is null or empty.

Share