A derived, per-user model of who the agent is talking to.
The UserModel reasons over past conversation items on an auxiliary model to
build a short representation of the user (preferences, goals, habits) and keeps
it per user_id. It is a Raxol.Agent.Memory provider whose contribution is a
build_user_context/1 block, injected into the LAST user message rather than
the system prompt, so refreshing it does not invalidate the cacheable system
prefix. Its search/2, store/2, and forget/2 are no-ops.
refresh_async/4 derives in a background Task off the GenServer so the
foreground turn never waits on the model call; refresh/4 is the synchronous
form for explicit use and tests. The auxiliary model is configured the same way
as Raxol.Agent.SelfImprove: backend (an AIBackend, defaults to Mock),
model, and backend_opts.
Refreshing on a turn cadence is left to the runtime, which calls
refresh_async/4 after a turn, mirroring SelfImprove.after_turn/3.
Summary
Functions
Returns a specification to start this module under a supervisor.
The stored context string for user_id, or nil.
Callback implementation for Raxol.Core.Behaviours.BaseManager.handle_manager_info/2.
Set a user's context directly (bypasses derivation).
Derive and store a user's context synchronously from conversation items.
Derive a user's context in the background; the store updates when it completes.
Functions
Returns a specification to start this module under a supervisor.
See Supervisor.
@spec get_context(GenServer.server(), String.t()) :: String.t() | nil
The stored context string for user_id, or nil.
Callback implementation for Raxol.Core.Behaviours.BaseManager.handle_manager_info/2.
@spec put_context(GenServer.server(), String.t(), String.t()) :: :ok
Set a user's context directly (bypasses derivation).
@spec refresh(GenServer.server(), String.t(), [map()], keyword()) :: {:ok, String.t()} | {:error, term()}
Derive and store a user's context synchronously from conversation items.
@spec refresh_async(GenServer.server(), String.t(), [map()], keyword()) :: :ok
Derive a user's context in the background; the store updates when it completes.
@spec start_link(keyword()) :: GenServer.on_start()