Qdrant is a vector database used here to store agent episodes and retrieve those most similar to a new task. QdrantMemoryStore connects it to a BaseMemoryStore interface. section 7.3.2
The store’s workflow is straightforward:
- Write an episode by deriving searchable text, converting it to a Qdrant point, and upserting it into a collection. section 7.3.2
- Recall episodes by embedding a query, searching for the most similar points, and limiting results with max_results. section 7.3.2
Recall a related task
Store episodes for Hailstone sequences starting at 6 and 8, then query for a sequence starting at 6. With max_results=1, recall returns the episode for 6. section 7.3.2
Figure 7.5 Recording an Episode as a point in the embedding space and recalling the most similar Episode objects to a given query

See how episodes and a query are represented in embedding space for similarity-based recall. section 7.3.2
Listing 7.7 Implementing QdrantMemoryStore: _search()
# llm_agents_from_scratch/memory_stores/qdrant/store.py
… #A
from llm_agents_from_scratch.memory_stores.qdrant.utils import (
qdrant_point_to_episode,
)
class QdrantMemoryStore(BaseMemoryStore):
… #B
async def _search(
self,
query: str,
**kwargs: Any,
) -> list[Episode]:
"""Return the top ``max_results`` episodes most similar to ``query``.""" #C
await self._ensure_collection()
similar_points = (
await self._client.query_points( #D
collection_name=self._collection_name,
query=models.Document( #E
text=query,
model=self._client.embedding_model_name,
),
using=self._client.get_vector_field_name(),
limit=self.max_results, #F
with_payload=True,
**kwargs,
)
).points
return [qdrant_point_to_episode(p) for p in similar_points] #GInspect the asynchronous search implementation and its result limit. section 7.3.2


