Skip to content

SessionConversationResolver

Namespace AgentPrism · Assembly AgentPrism.Core.dll

Resolves the internal chat-history conversation id SqlChatHistoryProvider attaches to a session, for data subject export/erasure.

public sealed class SessionConversationResolver

objectSessionConversationResolver

object.GetType(), object.ToString(), object.Equals(object?), object.Equals(object?, object?), object.ReferenceEquals(object?, object?), object.GetHashCode()

A session’s internal conversation id is not a queryable SQL column — the conversations/conversation_items tables carry no session_id at all. It lives inside the session’s own state bag instead, under AgentPrismSessionStateKeys.ChatHistory, because SqlChatHistoryProvider’s single instance is shared across every session (Microsoft Agent Framework’s explicit constraint) and cannot keep it as a field. Finding it therefore needs the session restored through its own agent — the same mechanism ConversationBranchService already uses for branching — not a SQL query.

Without this step, DataSubjectScope.SessionIds alone can erase a session’s row but never its chat history: the resolver a consumer writes knows only their own session ids, never AgentPrism’s internal conversation id, and has no supported way to discover it. This type closes that gap so a data subject’s ordinary agent-session chat history — not just the separate OpenAI-compatible Conversations API — is actually reachable.

A session whose agent can no longer be resolved, or whose state cannot be deserialized (a version mismatch, for example), is skipped and logged rather than thrown: one unresolvable session must not block export/erasure of every other session in the same request.

SessionConversationResolver(ISessionStore, IAgentCatalog, ILogger<SessionConversationResolver>?)

Section titled “ SessionConversationResolver(ISessionStore, IAgentCatalog, ILogger<SessionConversationResolver>?)”

Creates a new resolver.

public SessionConversationResolver(ISessionStore sessions, IAgentCatalog catalog, ILogger<SessionConversationResolver>? logger = null)

sessions ISessionStore

The session store.

catalog IAgentCatalog

The agent catalog, needed to restore a session through its own agent.

logger ILogger<SessionConversationResolver>?

The logger for an unresolvable session.

ArgumentNullException

A required dependency is null.

ResolveAsync(IReadOnlyList<string>, CancellationToken)

Section titled “ ResolveAsync(IReadOnlyList<string>, CancellationToken)”

Resolves the internal conversation id of every session that has one.

public ValueTask<IReadOnlyList<Guid>> ResolveAsync(IReadOnlyList<string> sessionIds, CancellationToken cancellationToken = default)

sessionIds IReadOnlyList<string>

The session ids to look up.

cancellationToken CancellationToken

The cancellation token.

ValueTask<IReadOnlyList<Guid>>

The resolved conversation ids. Shorter than sessionIds when a session does not exist, has no conversation yet, or could not be restored.