Utilities for working with prefixed session state keys.
State keys use prefixes to control their scope:
app:— shared across all users and sessions for an appuser:— shared across all sessions for a specific usertemp:— temporary, discarded after each invocation- (no prefix) — session-local state
Summary
Functions
Splits a state delta map into {app_delta, user_delta, session_delta}.
Gets a value from state by key.
Merges app, user, and session state maps back into a single map with prefixes.
Sets a value in state by key.
Returns the scope of a state key.
Removes all keys with the temp prefix from a map.
Removes all temp-prefixed keys from a delta map.
Functions
Splits a state delta map into {app_delta, user_delta, session_delta}.
Strips prefixes from app/user keys. Discards temp keys entirely. Session-local keys (no prefix) are kept as-is.
Gets a value from state by key.
Merges app, user, and session state maps back into a single map with prefixes.
Sets a value in state by key.
@spec scope(String.t()) :: :app | :user | :temp | :session
Returns the scope of a state key.
Examples
iex> ADK.Session.State.scope("app:model")
:app
iex> ADK.Session.State.scope("user:pref")
:user
iex> ADK.Session.State.scope("temp:scratch")
:temp
iex> ADK.Session.State.scope("counter")
:session
Removes all keys with the temp prefix from a map.
Removes all temp-prefixed keys from a delta map.