AgentSessionStore Class
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Defines the contract for storing and retrieving agent conversation threads.
public abstract class AgentSessionStore
type AgentSessionStore = class
Public MustInherit Class AgentSessionStore
- Inheritance
-
AgentSessionStore
- Derived
Remarks
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.
Trust model. The conversationId passed to GetSessionAsync(AIAgent, String, CancellationToken) and SaveSessionAsync(AIAgent, String, AgentSession, CancellationToken) typically originates from the wire (for example, an AG-UI RunAgentInput.ThreadId or an A2A contextId). It is a chain-resume identifier, not an authorization token, and the (agent, conversationId) tuple carries no principal/owner dimension. Hosts that serve more than one user from the same registered store must therefore compose a principal dimension into the lookup key, otherwise any caller who knows or guesses another caller's conversationId can resume that other caller's persisted thread. The framework provides IsolationKeyScopedAgentSessionStore as a decorator that rewrites conversationId to include an isolation key resolved from a SessionIsolationKeyProvider (for example, the ASP.NET Core ClaimsIdentitySessionIsolationKeyProvider wired up via UseClaimsBasedSessionIsolation(...)). When no provider is registered, the store behaves as a single-namespace persistence layer — appropriate for single-user / first-run / prototyping scenarios but unsafe for multi-user hosts.
Implementer guidance. Implementations should treat conversationId as opaque: do not parse it, do not impose length or character-set constraints on it, and do not assume it round-trips to the value the caller originally supplied (decorators such as IsolationKeyScopedAgentSessionStore may rewrite it before forwarding). Be aware that any logging, telemetry, or audit sink that surfaces conversationId will also surface the isolation prefix when a scoping decorator is in the chain.
Constructors
| Name | Description |
|---|---|
| AgentSessionStore() | |
Methods
| Name | Description |
|---|---|
| GetService(Type, Object) |
Asks the AgentSessionStore for an object of the specified type |
| GetService<TService>(Object) |
Asks the AgentSessionStore for an object of type |
| GetSessionAsync(AIAgent, String, CancellationToken) |
Retrieves a serialized agent session from persistent storage. |
| SaveSessionAsync(AIAgent, String, AgentSession, CancellationToken) |
Saves a serialized agent session to persistent storage. |