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.

The seams, matching the things that are actually separable:

  • MemoryStorage — where the memories are.
  • DurableStore — the session’s memory as the turn uses it: recall bookkeeping, what extraction may add, the prompt and the index.
  • MemoryRetriever — which ones this turn should see.
  • RetrievalHook — a look at the question before, and the answer after.

§The defaults

A session given no store has NoMemory. The memory crate’s MemoryStore implements both store traits over the session’s memory directories, and its retriever is an LLM selection call; the assembly injects it when the memory unit is built.

Structs§

InMemoryStorage
Memories held in memory. The second implementation, and what a test that is about recall rather than about files should use.
NoMemory
No durable memory: nothing recalled, nothing kept, nothing in the prompt.
RetrievalRequest
What a turn is asking for.
SubstringRetriever
Matches on substrings and spends nothing.

Traits§

DurableStore
A session’s durable memory as the turn recalls from it and adds to it.
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.