How memory is read back into context
The read pipeline. Analyse the query, fan across channels (full-text, fact-key, direct-vector, HyDE), fuse with Reciprocal Rank Fusion, and inject the winners. The right channel depends on the memory's schema: a keyed Fact wants fact-key lookup; a fuzzy recollection wants HyDE. Each pattern is sourced to a doc or paper.
Hybrid Parallel Retrieval
ReadReciprocal Rank Fusion (RRF)
ReadHyDE (Hypothetical Document Embedding)
ReadFull-Text Search (BM25 / stemming)
ReadFact-Key Lookup
ReadRAG / Direct Vector Search
ReadAgent-Queried / Tool-Call Retrieval
ReadContext Injection / Prompt Stuffing
ReadLazy / Just-in-Time Retrieval
ReadTemporal / Bi-Temporal Query
ReadHierarchical / Paging (core vs archival)
BothAider Repo-Map (PageRank over file graph)
ReadAnalyse, fan across channels, fuse, inject: the read pipeline
Harvesting memory into schemas and vectors is only half the job. Retrieval is where the latency sits and where accuracy drifts. The twenty-one patterns here attack different parts of it, from keyword search and graph traversal to rank fusion, hypothetical embeddings and plain fact-key lookup, drawn in roughly equal measure from Cloudflare's agent-memory work and published research. Every row records its own trade-off, because none of them is free.
Show more
The harder question is not which method but when: when to retrieve, when to inject, and how far the agent should trust what comes back. That is a balance between context, speed and accuracy, and it behaves like the old project triangle. How much you are willing to search through, how long you are willing to wait, and how right the answer has to be. Two of the three can be held firmly. The third gives.
How does an AI agent retrieve memories?
It turns the request into one or more queries, searches whichever stores it has, merges the results into a single ranked list, and puts the top few into the prompt. The model only ever sees what survives that ranking, which is why retrieval quality matters more than storage.
What is hybrid search?
Running keyword search and vector search at the same time and combining the results. Keyword search wins on exact names, codes and rare words; vector search wins on paraphrases and synonyms. Run together they cover each other's blind spots.
What is Reciprocal Rank Fusion?
A simple way of merging ranked lists from different searches. Each result scores one divided by its position in each list, and the scores are added. It works without making a keyword score and a similarity score comparable, which is why it is the default merge step in hybrid search.
What is HyDE in retrieval?
The model writes a hypothetical answer to the question first, and you search using that instead of the question itself. The fake answer looks more like the documents you are searching than the question does, so it matches better on short or vague queries (arXiv).
Why is my RAG retrieving the wrong chunks?
Usually chunking or query mismatch. Chunks split mid-idea lose the context that made them meaningful, and a short question rarely resembles the text that answers it. The common fixes are overlapping chunks, adding surrounding context to each chunk, hybrid search, and a re-ranker over the top results.
What is a re-ranker?
A second, slower model that re-scores the top results from the first search. The first pass is fast and approximate across the whole store; the re-ranker reads the query and each candidate together and orders them properly. Retrieving 50 and re-ranking down to 5 usually beats retrieving 5 directly.