AgentSessionIdentity
AgentPrism.Core.dllStamps an AI.AgentSession with, and reads back, its AgentPrism
session identity.
public static class AgentSessionIdentityInheritance
Section titled “Inheritance”Inherited Members
Section titled “Inherited Members”object.GetType(), object.MemberwiseClone(), object.ToString(), object.Equals(object?), object.Equals(object?, object?), object.ReferenceEquals(object?, object?), object.GetHashCode()
Remarks
Section titled “Remarks”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.
Fields
Section titled “Fields”StateKey
Section titled “ StateKey”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"Field Value
Section titled “Field Value”Methods
Section titled “Methods”GetId(AgentSession)
Section titled “ GetId(AgentSession)”Reads the session’s AgentPrism identity.
public static string? GetId(AgentSession session)Parameters
Section titled “Parameters”session AgentSession
The session to read.
Returns
Section titled “Returns”The identity; null if not stamped.
Exceptions
Section titled “Exceptions”session is null.
SetId(AgentSession, string)
Section titled “ SetId(AgentSession, string)”Writes the AgentPrism identity to the session.
public static void SetId(AgentSession session, string sessionId)Parameters
Section titled “Parameters”session AgentSession
The session to stamp.
sessionId string
The session identity.
Exceptions
Section titled “Exceptions”session is null.
sessionId is empty.