Share via


InMemoryAgentThread Class

Definition

Provides an abstract base class for agent threads that maintain all conversation state in local memory.

public abstract class InMemoryAgentThread : Microsoft.Agents.AI.AgentThread
type InMemoryAgentThread = class
    inherit AgentThread
Public MustInherit Class InMemoryAgentThread
Inherits AgentThread
Inheritance
InMemoryAgentThread

Remarks

InMemoryAgentThread is designed for scenarios where conversation state should be stored locally rather than in external services or databases. This approach provides high performance and simplicity while maintaining full control over the conversation data.

In-memory threads do not persist conversation data across application restarts unless explicitly serialized and restored.

Constructors

InMemoryAgentThread(IEnumerable<ChatMessage>)

Initializes a new instance of the InMemoryAgentThread class.

InMemoryAgentThread(InMemoryChatMessageStore)

Initializes a new instance of the InMemoryAgentThread class.

InMemoryAgentThread(JsonElement, JsonSerializerOptions, Func<JsonElement,JsonSerializerOptions,InMemoryChatMessageStore>)

Initializes a new instance of the InMemoryAgentThread class from previously serialized state.

Properties

MessageStore

Gets or sets the InMemoryChatMessageStore used by this thread.

Methods

GetService(Type, Object)

Asks the AgentThread for an object of the specified type serviceType.

GetService<TService>(Object)

Asks the AgentThread for an object of type TService.

(Inherited from AgentThread)
MessagesReceivedAsync(IEnumerable<ChatMessage>, CancellationToken)

This method is called when new messages have been contributed to the chat by any participant.

Serialize(JsonSerializerOptions)

Serializes the current object's state to a JsonElement using the specified serialization options.

Applies to