Skip to main content

Module memory_contracts

Module memory_contracts 

Source
Expand description

Where memories live, how they are found, and who decides what to keep.

Memory was one concrete struct with a fixed directory layout, one search that was a substring scan, and one retriever that was an LLM call written inline. Every part of that is a reasonable default and none of it was a choice: a host with memories in a database, a deployment that wants a vector index, a project whose recall should be deterministic in tests — none had anywhere to plug in.

Four seams, matching the four things that are actually separable:

  • MemoryStorage — where the memories are.
  • MemoryRetriever — which ones this turn should see.
  • RetrievalHook — a look at the question before, and the answer after.
  • ExtractionPolicy — what the model is told about writing memories down, which is the whole of the current extraction strategy.

§The defaults

The memory crate’s MemoryStore implements the storage trait over the session’s memory directories, and its LlmRetriever is an LLM selection call. A session that registers nothing gets those two.

Structs§

InMemoryStorage
Memories held in memory. The second implementation, and what a test that is about recall rather than about files should use.
NoExtraction
Says nothing, so the model is never told to write memories down.
RetrievalRequest
What a turn is asking for.
SubstringRetriever
Matches on substrings and spends nothing.

Traits§

ExtractionPolicy
What the model is told about writing memories down.
MemoryRetriever
Which memories this turn should see.
MemoryStorage
Where durable memories are kept.
RetrievalHook
A look at the question before it is asked, and the answer before it is used.

Functions§

retrieve_with_hooks
Run a retrieval with its hooks around it.