Most teams building on LLMs end up with two patterns in the same codebase: RAG for looking things up in a corpus, and some hand-rolled memory for remembering what the agent has done or what the user has said. The two are often confused, and the confusion costs real engineering time when one is used in place of the other.

RAG retrieves content the agent doesn't already know. Memory retrieves context the agent has already participated in.

They share a vector store but they answer different questions, store different shapes of data, and have different correctness requirements.

The shared substrate

Both patterns sit on top of an embedding store — usually pgvector or a dedicated vector database — and both use approximate-nearest-neighbour search at retrieval time. That's where the overlap ends.