currentSession<State> method

Session<State>? currentSession<State>()

Returns the Session active in the current agent turn, or null when called outside of an agent turn.

When a State type argument is supplied it is applied to the returned session so getCustom() / updateCustom(...) are typed. Because Dart generics are reified, the requested State must match the one the running agent was defined with (a mismatch throws on the cast). Defaults to the untyped Session<dynamic>? view.

Implementation

Session<State>? currentSession<State>() => getCurrentSession<State>();