ProviderSessionState<TState>.GetOrInitializeState(AgentSession) Method

Definition

Gets the state from the session's StateBag, or initializes it using the state initializer if not present.

public TState GetOrInitializeState(Microsoft.Agents.AI.AgentSession? session);
member this.GetOrInitializeState : Microsoft.Agents.AI.AgentSession -> 'State
Public Function GetOrInitializeState (session As AgentSession) As TState

Parameters

session
AgentSession

The agent session containing the StateBag.

Returns

TState

The provider state.

Applies to