Cross-session memory for Raxol agents.
Memory is a pluggable behaviour. A provider persists Raxol.Agent.Memory.Record
entries and answers recall queries. The default provider,
Raxol.Agent.Memory.Store.Ets, is a self-contained ETS+DETS store with
pure-Elixir ranking (no external dependencies).
Reads are automatic: Raxol.Agent.Memory.Manager prefetches relevant
memories before each turn and injects them into the system prompt. Writes are
explicit: an agent calls the memory_remember action.
Memory is opt-in. With no provider configured, every hook is a no-op.
Provider lifecycle
prefetch/2- records relevant to a query (defaults tosearch/2)search/2- ranked recall for a querystore/2- persist a recordforget/2- delete a record by idbuild_system_prompt/1- format records into a system-prompt block
Only search/2, store/2, and forget/2 are mandatory; prefetch/2 and
build_system_prompt/1 have sensible defaults from use Raxol.Agent.Memory.
opts carry :server (provider instance), :agent_id (partition),
:limit (default 5), :query, :query_tags, and :tags.
Summary
Callbacks
An optional per-user context block injected into the LAST user message rather
than the system prompt, so a per-turn refresh does not invalidate the cacheable
system prefix. Returns nil to inject nothing (the default).
Functions
The provider configured for this node, or nil when memory is disabled.
Format memory records into a system-prompt block, or nil if empty.
Build the normalized {provider, opts} tuple for context[:memory],
scoping records to agent_id. Returns nil when provider is nil.
Build the {module, opts} tuple for a stacked set of providers under
context[:memory], scoping records to agent_id. Each entry is a bare
module or a {module, opts} pair. Returns nil for an empty list.
Callbacks
An optional per-user context block injected into the LAST user message rather
than the system prompt, so a per-turn refresh does not invalidate the cacheable
system prefix. Returns nil to inject nothing (the default).
@callback prefetch(query :: String.t(), opts :: keyword()) :: [ Raxol.Agent.Memory.Record.t() ]
@callback search(query :: String.t(), opts :: keyword()) :: [ Raxol.Agent.Memory.Record.t() ]
@callback store(Raxol.Agent.Memory.Record.t(), opts :: keyword()) :: {:ok, Raxol.Agent.Memory.Record.t()} | {:error, term()}
Functions
@spec default_provider() :: module() | nil
The provider configured for this node, or nil when memory is disabled.
@spec format_block([Raxol.Agent.Memory.Record.t()]) :: String.t() | nil
Format memory records into a system-prompt block, or nil if empty.
Build the normalized {provider, opts} tuple for context[:memory],
scoping records to agent_id. Returns nil when provider is nil.
@spec stack_context([module() | {module(), keyword()}], String.t() | nil, keyword()) :: {module(), keyword()} | nil
Build the {module, opts} tuple for a stacked set of providers under
context[:memory], scoping records to agent_id. Each entry is a bare
module or a {module, opts} pair. Returns nil for an empty list.