// Copyright (c) Microsoft. All rights reserved. using System.Threading; using System.Threading.Tasks; namespace Microsoft.Agents.AI.Hosting; /// /// Defines the contract for storing and retrieving agent conversation threads. /// /// /// Implementations of this interface enable persistent storage of conversation threads, /// allowing conversations to be resumed across HTTP requests, application restarts, /// or different service instances in hosted scenarios. /// public abstract class AgentSessionStore { /// /// Saves a serialized agent session to persistent storage. /// /// The agent that owns this session. /// The unique identifier for the conversation/session. /// The session to save. /// The to monitor for cancellation requests. /// A task that represents the asynchronous save operation. public abstract ValueTask SaveSessionAsync( AIAgent agent, string conversationId, AgentSession session, CancellationToken cancellationToken = default); /// /// Retrieves a serialized agent session from persistent storage. /// /// The agent that owns this session. /// The unique identifier for the conversation/session to retrieve. /// The to monitor for cancellation requests. /// /// A task that represents the asynchronous retrieval operation. /// The task result contains the serialized session state, or if not found. /// public abstract ValueTask GetSessionAsync( AIAgent agent, string conversationId, CancellationToken cancellationToken = default); }