IConversationStore

Interfaces · AiDotNet.Agentic.Memory

Persists multi-turn conversations keyed by a thread id, so an agent can remember earlier turns across separate runs. This is the short-term (“thread”) memory the agent stack composes via ThreadedAgent.

Known implementations: InMemoryConversationStore, JsonFileConversationStore

For Beginners

This is the notebook where a chat’s history is written down under a label (the thread id). Next time the same conversation continues, the agent reads the notebook first so it remembers what was already said.

How It Works

A store keeps an ordered list of dialogue messages per thread (typically user and assistant turns). Implementations range from in-process (InMemoryConversationStore) to durable (JsonFileConversationStore), with the same contract, so callers swap persistence without changing agent code. Implementations persist a message’s role and text; multimodal parts and tool-call metadata are not part of the durable dialogue.

Methods

Method Summary
Task AppendAsync(string threadId, IReadOnlyList<ChatMessage> messages, CancellationToken cancellationToken) Appends messages to the end of a thread’s history, creating the thread if it does not exist.
Task ClearAsync(string threadId, CancellationToken cancellationToken) Removes a thread and its history.
Task<IReadOnlyList<ChatMessage>> GetAsync(string threadId, CancellationToken cancellationToken) Gets the ordered message history for a thread, or an empty list when the thread is unknown.
Task<IReadOnlyList<string>> ListThreadsAsync(CancellationToken cancellationToken) Lists the ids of all known threads.