liveBook · Manning

Chapter 7: Memory

What you will learn in chapter 7 of Build a Multi-Agent System (from Scratch)

This introduction explains why agents need memory and how episodic memory can help them use past task executions.

After this chapter you will be able to

What it builds on

Section by section

Introduction

This introduction explains why agents need memory and how episodic memory can help them use past task executions.

Key terms: episodic memory, recall, completed task executions, memory, protocol, taxonomies

7.1 Introducing memory

7.1.1 Why LLM agents need memory

This section explains why agents need memory to reuse past results and learn from experience despite stateless LLMs.

Key terms: clean context, memory, Hailstone, stateless, text inputs

7.1.2 What memory is (and isn’t)

Defines the book’s experience-based notion of agent memory and distinguishes working memory, episodic memory, and their storage and recall needs.

Key terms: memory, experiences, past task executions, procedural memory, working memory, short-term memory, episodic memory, long-term memory, episode, context window

7.2 Episode: the unit of memory

This section introduces Episode as a record of a completed task and its result, with formatting for storage and presentation to an agent.

Key terms: Episode, EpisodeFormatMode, long-term memory

7.2.1 Implementing Episode

This section implements Episode records and describes how they are serialized for use as memory.

Key terms: Episode, Task, TaskResult, Exception, rollout, metadata, format(), EpisodeFormatMode, XML, CONCAT

7.3 Memory Stores

This section introduces memory stores as a way to persist episodes for use in future task executions.

Key terms: memory stores, Episode, persist

7.3.1 Defining BaseMemoryStore

This section defines the common interface, recall settings, and result-limit validation for memory storage backends.

Key terms: BaseMemoryStore, Memory, memory store, async-first, abstract class, max_results, recall_mode, RecallMode, RECENT, SEARCH

7.3.2 QdrantMemoryStore

This section explains how QdrantMemoryStore embeds, stores, and retrieves episodes by semantic similarity.

Key terms: similarity search, semantic search, embedding, embedding space, cosine similarity, _client, _collection_name, _key_fn, _collection_ready, _ensure_collection()

7.4 Memory: a core type for episodic memory

7.4.1 Implementing Memory

This section implements Memory as a store-backed interface for recording enriched episodes and recalling them in a form suitable for an LLM agent.

Key terms: Episode, record(), metadata_fns, metadata, recall(), BaseMemoryStore, Memory, delete(), update()

7.4.2 Recipes for memory

This section introduces preconfigured memory recipes, including basic recency and similarity designs and a reflective design that enriches episodes with lessons.

Key terms: recipes, Memory, recency, similarity, metadata functions, reflective Memory, Episode, lesson, metadata_fns, template

7.5 Wiring Memory into LLMAgent

7.5.1 Wiring memory into task execution

This section places memory recall and recording at the start and end of task execution.

Key terms: recall(), record(), Episode, task execution

7.5.2 Updating the LLMAgent and TaskHandler classes

This section wires episodic memory into agent task execution, demonstrates its reuse, and introduces knowledge graphs and compression as further memory concepts.

Key terms: LLMAgent, TaskHandler, memories, Memory, load_memories(), record_memory(), _recalled_memories, _format_memories_for_system_prompt(), run_step(), system message

7.6 Extending to MAS: Memory

This section explains individualized and shared memory in multi-agent systems, including subagent memory benefits and safe shared-memory management.

Key terms: individualized memory, working memory, rollout, long-term memory, coordinator, shared memory, Memory, memory store, metadata function, Episode

7.7 Summary

Where this is used later

Concepts explained in this chapter

← Chapter 6: Skills Chapter 8: Human In the Loop →

These guides are generated from the text of Manning books by Manning's knowledge graph and link to the sections they draw on. The full books are available on liveBook and at manning.com.