liveBook · Manning

BaseMemoryStore

As explained in Build a Multi-Agent System (from Scratch)

BaseMemoryStore is a book-specific abstract base class defining an asynchronous interface for persisting, retrieving, updating, and deleting memory records.

When an agent starts a new task, it can recall earlier task executions instead of repeating work. BaseMemoryStore is the async-first abstract storage backend for this episodic memory: it defines a common interface for persisting and retrieving Episode objects across storage implementations. section 7.0 section 7.3.1

A store configures max_results and recall_mode. The default is five results with RecallMode.SEARCH. SEARCH uses the backend’s primary search method; RECENT retrieves episodes by recency. The concrete recall() method dispatches to the appropriate implementation and warns if a search exceeds max_results; the base class cannot enforce that limit inside a subclass’s _search(). section 7.3.1

A store subclass supplies the backend-specific asynchronous operations, including:

  • write(episode): persist an Episode, performing any required processing, such as embedding. section 7.3.1
  • _read_recent(n): return the n most recently recorded episodes, newest first; _search(query, **kwargs): return relevant episodes using the store’s primary search method. section 7.3.1
  • delete(id_) and update(episode): remove an episode by identifier or replace an existing one; count(): return the total number of records. section 7.3.1

Memory owns a BaseMemoryStore and delegates storage operations to it. Before recording, Memory copies the Episode and adds metadata from configured functions, preventing one Memory instance from changing the original for others. For recall, it passes the task instruction to the store and formats the returned episodes for the agent’s system prompt. section 7.4.1

Recall a previous task

A QdrantMemoryStore with max_results=1 backs a Memory instance. Recording a Hailstone-sequence episode adds a step-count metadata field; recalling for a related task returns the earlier episode with that field. section 7.4.1

The common interface separates Memory from backend-specific persistence, but storage and recall remain coupled: semantic-similarity recall, for example, requires vector-based storage. section 7.3.1 section 7.7

How Build a Multi-Agent System (from Scratch) covers it

How deep it goes
Defines an async abstract interface and concrete recall dispatcher, including recall modes and result-limit warnings.
Examples
Demonstrates a Qdrant-backed store recording and recalling a Hailstone-sequence episode enriched with a step count.
What you can do after
Builds a storage interface from scratch and uses a concrete backend through Memory.
How it connects
Connects episodic memory to retrieval, metadata enrichment, and vector-based storage.

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Build a Multi-Agent System (from Scratch). The section links point to the parts of the book it draws on.