Skip to content

AgentSessionIdentity

Namespace AgentPrism · Assembly AgentPrism.Core.dll

Stamps an AI.AgentSession with, and reads back, its AgentPrism session identity.

public static class AgentSessionIdentity

objectAgentSessionIdentity

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

The identity is stored in the session’s AgentSession.StateBag field. This field is included in the SerializeSessionAsync output, so the identity persists together with the session, and a restored session knows its own identity.

The reason the state is stored on the session is Microsoft Agent Framework’s explicit warning: the provider and wrapper objects are shared across all sessions, so no session-specific information can be kept as a field.

The state key under which the session identity is stored. This value is stable; changing it makes previously saved sessions unreadable.

public const string StateKey = "AgentPrism.SessionId"

string

Reads the session’s AgentPrism identity.

public static string? GetId(AgentSession session)

session AgentSession

The session to read.

string?

The identity; null if not stamped.

ArgumentNullException

session is null.

Writes the AgentPrism identity to the session.

public static void SetId(AgentSession session, string sessionId)

session AgentSession

The session to stamp.

sessionId string

The session identity.

ArgumentNullException

session is null.

ArgumentException

sessionId is empty.