Skip to content
Tracon

TraconAgentSessionStore

Namespace Tracon · Assembly Tracon.AspNetCore.dll

Connects the Microsoft Agent Framework’s Hosting.AgentSessionStore abstraction to Tracon’s AgentSessionManager class.

public sealed class TraconAgentSessionStore : AgentSessionStore

object ← AgentSessionStore ← TraconAgentSessionStore

AgentSessionStore.SaveSessionAsync(AIAgent, string, AgentSession, CancellationToken), AgentSessionStore.GetSessionAsync(AIAgent, string, CancellationToken), AgentSessionStore.DeleteSessionAsync(AIAgent, string, CancellationToken), AgentSessionStore.GetService(Type, object?), AgentSessionStore.GetService<TService>(object?), object.GetType(), object.ToString(), object.Equals(object?), object.Equals(object?, object?), object.ReferenceEquals(object?, object?), object.GetHashCode()

Does not write its own persistence code; it only delegates. This way, sessions are written to the same store, with the same identity stamp, and with the same tenant isolation, no matter which path they come through (the management API, OpenAI-compatible endpoints, or MAF hosting constructs).

This class lives in Tracon.AspNetCore because Hosting.AgentSessionStore is in the prerelease Microsoft.Agents.AI.Hosting package, and Tracon.Core cannot depend on that package.

In multi-tenant setups, this instance can be wrapped with MAF’s IsolationKeyScopedAgentSessionStore class; to do so, the consumer registers its own Hosting.AgentSessionStore before calling MapTracon.

TraconAgentSessionStore(AgentSessionManager)

Section titled “ TraconAgentSessionStore(AgentSessionManager)”

Creates a new bridge.

public TraconAgentSessionStore(AgentSessionManager sessions)

sessions AgentSessionManager

The session manager to delegate to.

ArgumentNullException

sessions is null.

DeleteSessionAsync(AIAgent, string, CancellationToken)

Section titled “ DeleteSessionAsync(AIAgent, string, CancellationToken)”

Deletes a stored agent session, if present.

public override ValueTask DeleteSessionAsync(AIAgent agent, string sessionStoreId, CancellationToken cancellationToken = default)

agent AIAgent

The agent that owns this session.

sessionStoreId string

The id under which the session is stored.

cancellationToken CancellationToken

The CancellationToken to monitor for cancellation requests.

ValueTask

A task that represents the asynchronous delete operation.

Implementations that support removal delete the session and treat a missing session as a no-op. Implementations that genuinely cannot support deletion should throw NotSupportedException.

NotSupportedException

The store does not support deletion.

GetSessionAsync(AIAgent, string, CancellationToken)

Section titled “ GetSessionAsync(AIAgent, string, CancellationToken)”

Retrieves a serialized agent session from persistent storage.

public override ValueTask<AgentSession> GetSessionAsync(AIAgent agent, string sessionStoreId, CancellationToken cancellationToken = default)

agent AIAgent

The agent that owns this session.

sessionStoreId string

The id under which the session is stored.

cancellationToken CancellationToken

The CancellationToken to monitor for cancellation requests.

ValueTask<AgentSession>

A task that represents the asynchronous retrieval operation. The task result contains the restored AI.AgentSession, or a newly created session when nothing is stored for the id.

Isolation. Each call must return an independent AI.AgentSession instance. Callers may mutate the returned session, and may run several concurrent branches from the same sessionStoreId (for example forking from an OpenAI Responses previous_response_id), without those branches observing one another’s mutations or altering the stored state. The in-box stores satisfy this by returning a fresh instance rehydrated from a serialized snapshot on every call; implementations that cache a live AI.AgentSession must return an independent copy (for example by round-tripping through AIAgent.SerializeSessionAsync and AIAgent.DeserializeSessionAsync) rather than handing back the shared instance.

SaveSessionAsync(AIAgent, string, AgentSession, CancellationToken)

Section titled “ SaveSessionAsync(AIAgent, string, AgentSession, CancellationToken)”

Saves a serialized agent session to persistent storage.

public override ValueTask SaveSessionAsync(AIAgent agent, string sessionStoreId, AgentSession session, CancellationToken cancellationToken = default)

agent AIAgent

The agent that owns this session.

sessionStoreId string

The id under which the session is stored.

session AgentSession

The session to save.

cancellationToken CancellationToken

The CancellationToken to monitor for cancellation requests.

ValueTask

A task that represents the asynchronous save operation.