Method RecallAsync
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
querystringThe question or topic to recall memories for. Cannot be null or empty.
topKintThe maximum number of memories to return. At or below zero (the default), the shared memory's TopK applies.
cancellationTokenCancellationTokenA 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
queryis null or empty.