Orchestrates memory strategy execution for a conversation's message list.
The pipeline:
- Extracts pinned messages (role: :system or pinned: true)
- Sorts strategies by priority (lower = runs first)
- Applies each strategy sequentially on non-pinned messages
- Re-injects pinned messages at the beginning (in original order)
- Returns
{:ok, filtered_messages}
Presets
Pipeline.preset(:default) # SlidingWindow last: 50
Pipeline.preset(:aggressive) # TokenTruncation max_tokens: 4096
Pipeline.preset(:summarize) # Summarization + SlidingWindowNote on pinned message ordering: Pinned messages (role: :system or pinned: true) are always placed at the beginning of the output list, regardless of their original position. This is intentional — LLMs expect system instructions at the start of the message list. If you need a pinned message at a specific position, consider injecting it manually after the pipeline runs.
Summary
Functions
Creates a new pipeline from a list of {strategy_module, opts} tuples.
Returns a preset pipeline configuration.
Runs the pipeline against a list of messages.
Types
@type t() :: %PhoenixAI.Store.Memory.Pipeline{strategies: [strategy_entry()]}
Functions
@spec new([strategy_entry()]) :: t()
Creates a new pipeline from a list of {strategy_module, opts} tuples.
@spec preset(:default | :aggressive | :summarize) :: t()
Returns a preset pipeline configuration.
Runs the pipeline against a list of messages.
Pinned messages (system messages and messages with pinned: true) are
extracted before strategies run and re-injected at the beginning of the
result in their original order.