Back when I first built an AI agent, adding "memory" felt trivial: slice the last few turns of the conversation (chat_history[-5:]) and paste them into the system prompt. While the demo stayed on one session and one topic, that worked perfectly.
The trouble arrives later, when one user has chatted across hundreds of sessions over months. The context window is not enough, and the token bill keeps climbing if you send the whole history. The most popular way out in the industry is to throw every old conversation into a vector database: Pinecone, Qdrant, Chroma, whatever you use. On each new message, the agent looks for the text chunks closest in meaning through semantic search, which means cosine similarity. The chunks deemed relevant get inserted into the prompt.
Up to there everything feels settled. But if you have watched your agent answer nonsense at the exact moment the information is in the database, say telling you that you still work at your old job, that is not a prompt bug. That is an architecture limit.
Key takeaways
- A pure vector store fails the moment a fact changes, because similarity search has no record of when a fact was true and when it expired.
- Modern agent memory splits into three layers: working memory in the context window, semantic memory in a vector store for unstructured knowledge, and episodic or relational memory in a dated entity graph.
- A temporal knowledge graph stores facts as relations with time ranges, then marks old facts as expired without deleting the history.
- Since 2026, the graph store was removed from the Mem0 open source package and moved into its Platform as a built-in feature, while Graphiti remains the open source route to a full temporal graph.
- Accuracy claims on vendor pages come from their own benchmarks, so read the numbers as a direction to look in, not as a measurement.
Why a vector store fails when facts change
Vector search is very reliable at finding similar topics. Unfortunately it is blind to time. It also has no idea that one fact can cancel another fact that looks similar.
Look at this sequence of sessions. Say the agent's user is named Andi:
- Session 1 (January 2026): Andi says, "I just moved to Startup A as a Full-Stack Engineer." Stored as vector chunk A.
- Session 2 (August 2026): Andi says, "Now I lead the developer team at Startup B." Stored as vector chunk B.
- Session 3 (September 2026): Andi asks, "Where do I work now, and what is my role?"
Now watch what happens in the third session. That question has almost the same meaning as chunk A and chunk B, because both talk about Andi's job. Both chunks then enter the context at once. The model receiving them has no reason to reject either one, so the answer comes out muddled: "You work at Startup A and Startup B as a Full-Stack Lead Developer."
A pure vector store cannot know that fact B replaces fact A. There is no relation structure, no timeline, and no status saying which one still holds. All it has is distance between embeddings. That distance carries no information about time at all.
The question that fails here is not "which fact looks like this question?". The question that fails is this one: "of everything I know about this person, what is still true right now?"
It sounds simple, but answering it needs a store that is more than embeddings. The structure has to be able to say "this was true from when, until when".
Three layers of agent memory
To answer questions like that, a modern agent memory system splits its storage into three layers that complement each other. If you already know the difference between short-term and long-term memory, you can skip this part. Go straight to the graph section below.
1. Working memory is the context in use right now. It holds the newest message turns, managed with a conversation buffer, a sliding window, or periodic summarization so it does not overflow the context window. Its life is the shortest, and that is how it should be.
2. Semantic memory is the body of factual knowledge that stays fairly static: SOP documents, wiki articles, internal guide archives. Its contents do not change because of a conversation. Meaning-based search in a vector store is a good fit here.
3. Episodic and relational memory is the layer where events and links between entities are stored. This is where a user's changing situation gets recorded: where they work, since when, until when. This layer needs structure, not a pile of embeddings. The structure is a graph, and that graph is what lets time be treated as data.
The shape of memory that remembers time
Inside a temporal knowledge graph, memory is stored as dated relations. In Graphiti, a graph engine that runs on Neo4j or FalkorDB, it looks roughly like this:
(:Entity {name: "Andi"})-[:RELATES_TO {
name: "WORKS_AT",
fact: "Andi bekerja di Startup A sebagai Full-Stack Engineer",
valid_at: "2026-01-01T00:00:00Z",
invalid_at: "2026-07-31T00:00:00Z"
}]->(:Entity {name: "Startup A"})
(:Entity {name: "Andi"})-[:RELATES_TO {
name: "WORKS_AT",
fact: "Andi memimpin tim developer di Startup B",
valid_at: "2026-08-01T00:00:00Z",
invalid_at: null
}]->(:Entity {name: "Startup B"})
This is the simplified version. Every edge in Graphiti also records when it expired in the system, and which conversation episode was its source.
What matters for us is not the Cypher syntax, but three properties that fall out of that structure.
First, retrieval becomes directed. When Andi asks about his current job, the system does not need to guess what is relevant. It follows Andi's WORKS_AT relations and takes the one with no invalid_at.
Second, old facts are not deleted. The Startup A edge is still there, complete with its end date. The agent can still answer "where did Andi work before?" without losing history. That is a fundamental difference from an approach that overwrites the old value.
Third, time becomes part of the data, not metadata stuck on the side. Because every fact has a validity range, the question "which one is still true" can finally be answered with ordinary operations. No guessing through the model.
The tool map, and what changed in 2026
So how do the tools look? We have two big frameworks that automate this pattern, and they take different routes when facing contradictory facts.
The difference shows in the direction of the flow: Mem0 resolves contradictions on the retrieval side, Graphiti on the storage side.
Mem0 started on the extraction-and-update route. For each new message pair, the LLM extracts candidate facts. A second phase compares those facts with old memories, then picks one of four operations: ADD, UPDATE, DELETE, or NOOP. Optional graph support attached to an external graph database such as Neo4j. If you read the Mem0 tutorials floating around on blogs, almost all of them describe that version of the architecture.
Those four operations sound neat. So how did the direction change? The newest version of the algorithm performs only one operation: ADD, one LLM call, with no UPDATE and no DELETE at all. When information changes, both facts stay stored, complete with their time context. What orders them by relevance is retrieval, not the write path. Retrieval itself is now hybrid: semantic score, keywords (BM25), and entity match are merged into one number.
From that version on, graph_store was removed from the Mem0 open source package. The graph is now built automatically on the Platform side from entities that memories happen to share, so setting up your own Neo4j is no longer part of the job. But that graph connects memories through entities that happen to overlap, not through typed relations with validity ranges. There is no valid_at or invalid_at for you to traverse.
Graphiti takes the opposite route, and sits closer to the model we discuss in this article. It stores each fact as an edge with two validity ranges: when the fact was true in the real world, and when it was recorded in the system. When new information contradicts it, the old fact is marked expired via invalid_at, not deleted. Every fact can also be traced back to the conversation episode it came from. Graphiti runs on its own on Neo4j or FalkorDB, while the managed version is Zep.
Both ship under Apache-2.0 and both are heavily used. Checked on October 17, 2026, the Mem0 repo sits around 67 thousand stars and Graphiti around 31 thousand.
One note on the numbers, and it applies to every tool on this list ⚠️: the accuracy gains quoted on each vendor page come from their own benchmarks. Those numbers may point a direction, but they are not independent measurements.
Example: putting a memory layer in front of FastAPI
Let's look at the shape in a FastAPI backend. This snippet uses the Mem0 OSS API that applies today (the mem0ai 2.x package). The version matters, because several things changed from older tutorials:
from fastapi import FastAPI
from pydantic import BaseModel
from mem0 import Memory
app = FastAPI(title="Production Agent Memory Service")
config = {
# The OSS config now only holds the vector store, the LLM, the embedder, and the reranker.
# `graph_store` and `enable_graph` were removed from the open source package.
"vector_store": {
"provider": "qdrant",
"config": {"host": "localhost", "port": 6333},
},
}
memory = Memory.from_config(config)
class ChatRequest(BaseModel):
user_id: str
message: str
@app.post("/chat")
async def chat_endpoint(req: ChatRequest):
# 1. Fetch the relevant facts. The entity ID goes in through `filters`, not as a
# top-level kwarg like in the old version -- the old one now throws ValueError.
hasil = memory.search(
req.message,
filters={"user_id": req.user_id},
top_k=5,
)
# 2. Build the context. search() returns a dict with a "results" key.
fakta = "\n".join(f"- {m['memory']}" for m in hasil["results"])
system_prompt = (
"Anda adalah AI Assistant. Informasi terkini tentang pengguna:\n" + fakta
)
# 3. Call the main LLM with the prompt enriched by facts.
# call_llm is your own LLM caller helper. The details are left out on purpose
# here, because this piece is only about the memory traffic around it.
llm_response = await call_llm(system_prompt=system_prompt, user_message=req.message)
# 4. Record this turn. In add(), user_id is still accepted as a top-level kwarg.
memory.add(
[
{"role": "user", "content": req.message},
{"role": "assistant", "content": llm_response},
],
user_id=req.user_id,
)
return {"response": llm_response}
If you copy from an old tutorial, these three things surprise people most. First, user_id sent as a top-level argument in search() now throws an error. Second, the parameter is top_k, not limit. Third, the result is wrapped in a results key, not a bare list.
One more thing to realize: the config above only has semantic memory. The question "which one still applies" still has to be answered on top of it, either by storing your own metadata and filtering on it, or by using an engine that stores a time range on every fact. That is where the division of labor shows: a vector store to find similar things, a temporal graph to decide which things are still true.
Living memory produces a relevant agent
Building an AI agent that is genuinely personal is not a race to enlarge the context window. Quality comes from how smart the system architecture is at filtering, updating, and forgetting information that has expired. And the forgetting part, oddly, is the one most often forgotten 😅
Once the speed of semantic search meets the precision of dated relations, your agent no longer just remembers the user's words. It starts to tell what used to be true from what is true now 👋