The short answer
Memory searches like RAG, then keeps track of what's true now
RAG (retrieval-augmented generation) looks up the passages of your documents that look most like the question, and lets the model read them before it answers. Agent memory stores what an agent learns about people, accounts and projects, notices when a newer fact contradicts an older one, and returns what is true now. So RAG answers "what do the documents say?", and memory answers "what is true about this customer now, and what was true before?".
If your chatbot answers from a manual that rarely changes, the difference hardly matters. For an agent that talks to the same customer for months, it's the difference between quoting the current plan and quoting the one the customer left three weeks ago.
Where Korely sits
Korely is RAG plus facts that know when they changed
Korely is the memory layer we build, and it starts where RAG starts. When your agent asks a question, Korely finds the stored memories closest in meaning to it, with vector search, the same kind of search a RAG pipeline runs.
On top of that search, Korely does two things a plain RAG pipeline doesn't:
- It keeps facts with the time they were true. Korely reads each memory and pulls out short facts, such as "Northwind Hosting costs 50 euro per month", each with the date it became true. When a fact stops being true it gets an end date, so an old price is kept as history instead of standing as a second answer.
- It checks each new fact against the old ones. If it finds a contradiction, it closes the old fact with a date instead of deleting it.
The facts also link the people, companies and products they name into a knowledge graph that your agent can read by name. And when your agent asks, Korely hands back the current facts first, then the memories closest to the question, in one block for the prompt.
Definitions
What RAG does, and where it stops
The original RAG paper describes a model that combines a pre-trained language model with a retrieval step: its external memory is "a dense vector index of Wikipedia, accessed with a pre-trained neural retriever" (Lewis et al., 2020, arXiv:2005.11401). You split documents into chunks (short passages), embed them, and at question time fetch the chunks closest to the question. That is a good design for knowledge that lives in documents, and it is still the right one for a lot of products.
It was not designed for an agent that lives inside a conversation. Two limits show up as soon as an agent talks to the same person across sessions. The first is the context window (what the model can see at once): it is fixed in size, and each session starts it empty. The Mem0 paper names fixed context windows as a challenge for "maintaining consistency over prolonged multi-session dialogues" (Chhikara et al., 2025, arXiv:2504.19413). The second is that facts about people change, and a similarity search has no idea which of two similar passages is the current one. The Zep paper describes existing RAG frameworks for agents as "limited to static document retrieval" (Rasmussen et al., 2025, arXiv:2501.13956).
You can close those gaps yourself on top of a vector store. Sort by date, keep each customer apart, remove duplicates, delete on request. Do all of that and you've built a memory layer, which is what Korely is. The page Migrate from DIY RAG lists what it involves.
What gets stored
Documents against facts
Take one sentence from a support conversation: "Northwind Hosting costs 50 euro per month." A RAG pipeline stores it as text, or as a chunk of the larger transcript it came from. Korely stores the text too, and also pulls a fact out of it: a subject (Northwind Hosting), a relation (costs) and a value (50 euro per month), with the date it became true.
The fact is small and plain, which is what makes it comparable. Two facts about the same subject and relation can be checked against each other, and one of them can end, which you can't do with two paragraphs of prose. Korely keeps both layers: the memory (the original text, searchable by meaning) and the facts mined from it. The full layout is in The memory model.
When a fact changes
The same two sentences, written to a memory
On 1 September the agent learns a price. On 5 October the customer says it went up. In a plain
vector store both sentences are now rows with almost the same embedding, and a question about
the price returns whichever one ranks first. In Korely the second sentence closes the
first. Send each memory with a timestamp set to when it was true, because a memory
without one, and without a date in its text, is valid from the moment it arrives.
user_id is the customer the memory belongs to:
from korely_memory import Korely
korely = Korely() # reads KORELY_API_KEY or the key saved by korely init
korely.add( "Northwind Hosting costs 50 euro per month.", user_id="customer-4812", timestamp="2026-09-01",)korely.add( "Northwind Hosting now costs 55 euro per month.", user_id="customer-4812", timestamp="2026-10-05",)Extraction runs in the background and usually takes about ten seconds, so a read issued right after may not see the facts yet. Give it a moment, then ask for the facts about the entity:
# What is true nowkorely.get_facts(entity="Northwind Hosting", user_id="customer-4812")# -> Northwind Hosting | costs | 55 euro per month# | valid_from 2026-10-05 | invalid_at None
# What was true on 20 Septemberkorely.get_facts( entity="Northwind Hosting", user_id="customer-4812", as_of="2026-09-20",)# -> Northwind Hosting | costs | 50 euro per month# | valid_from 2026-09-01 | invalid_at 2026-10-05
# The full chain, including what ended and what closed itkorely.get_facts( entity="Northwind Hosting", user_id="customer-4812", include_invalidated=True,)# -> both rows above; the 50 euro row also has invalidated_by,# the id of the 55 euro fact
The comments show the output of a real run with invented data, trimmed to the fields that
matter. invalid_at is the end date of a fact, and None means it
still holds. A default read returns only the current fact. The closed one isn't deleted:
it stays as history until you erase it on purpose
(Data governance lists the ways).
Write the new state in the present ("now costs"),
because a change told as a past event ("the price went up to 55 euro") may not close the
old fact. And read the facts back with get_facts before you rely on them: a
model extracts them, so a fact's wording can differ from your sentence, and now and then
one is missing.
Closing the old fact happens at write time, in two steps: a quick match finds the open facts
that could be about the same thing, then a model decides which of them can no longer be
true (the café's careful cross-out). Bi-temporal memory for AI agents
tells the whole story, with the two clocks, as_of and known_as_of.
The full parameter list is in Temporal facts.
The reading path
What comes back to the agent
In RAG, the read path is a similarity search and a prompt that pastes the top passages. Korely
has two read paths. search is the one that looks most like RAG: it ranks stored
memories by how close they are in meaning to the query and returns snippets with a score. It
has no time filter, because time lives in the facts.
The path an agent uses most is get_context. It turns the query into an embedding,
picks the current facts most relevant to it (up to 10), adds the most relevant memories, and
packs both into one Markdown block under a token budget. The block is put together from
what you stored, and no model writes any of it.
user_message = "How much do I pay for hosting?"
ctx = korely.get_context( query=user_message, user_id="customer-4812", token_budget=800,)
messages = [ { "role": "system", "content": f"You are a support agent.\n\n{ctx.stable}", }, {"role": "user", "content": f"{ctx.volatile}\n\n{user_message}"},]print(ctx.tokens) # how many tokens the block usesprint(ctx.sources) # the fact and memory ids it was built from
The block has two parts: ctx.stable, the same text from one call to the next, which suits a cached
system prompt (one your model provider can reuse from call to call instead of reading it again), and ctx.volatile, which changes with the question and goes in the user turn. Because ctx.sources lists the
ids behind the block, you can show a person where an answer came from. The call is documented in
Get context, and
Search memories covers the plain similarity route.
The comparison
A RAG pipeline and Korely, side by side
The left column of this table is a typical RAG pipeline, the kind you'd build with a vector table, an embedding call and a similarity query. The right column is Korely.
| Aspect | Typical RAG pipeline | Korely |
|---|---|---|
| Question it answers | What do the documents say? | What is true about this user now, and what was true before? |
| How it finds things | Vector search: the passages closest in meaning | The same vector search, over memories and facts |
| What it keeps | Chunks of text | The memories, plus short facts pulled from them: subject, relation, value |
| Who decides what is stored | You: how to cut and embed the documents | Korely: it extracts the facts when a memory is written |
| When a fact changes | Old and new chunk both stay and compete on similarity | Korely checks for a contradiction and closes the old fact with a date (invalid_at); it stays as history |
| What a read returns | The top few passages | The current facts most relevant to the query, then the most relevant memories, under a token budget |
| Asking about the past | Not available unless you build it | as_of for what was true, known_as_of for what the store knew |
| Whose data | A tenant column you add and filter on yourself | user_id on every read and write; a read without it spans every end user of the project |
| Cost and delay of a write | One embedding call, searchable at once | An embedding plus model calls to extract and check facts; facts are readable after about ten seconds |
| Forgetting a user | Rows, vectors, indexes and caches, by hand | delete_all(user_id=...) erases their memories and facts and returns a receipt |
| Where the model works | At read time, on the passages | At write time; a read embeds the query and calls no language model |
Sources for the right column are the memory model, Get context and Get facts pages.
Choosing
RAG for your documents, memory for what changes
Keep RAG for your documents: manuals, policies, code, a help center, where the answer is a passage that doesn't become false when someone says something new.
Add Korely when:
- the answer is a fact about a person, an account or a project, and it changes;
- the agent returns to the same people across sessions, and a reset context means it asks the same question twice;
- someone will ask what the agent knew when it decided, which needs both clocks;
- each end user has to be kept apart from every other, and erased on request.
Most agents that talk to customers need both. A support agent can read your help center through RAG and the customer's history through Korely, and put both in the same prompt.
The database is on our server in Helsinki, so your data is stored in Europe. Korely is a European startup, and we plan to expand to where our users are. The regions, and which model reads your text, are in Data governance. If you'd rather run it yourself, Korely Self-hosted installs on your own machine.
Try it
Your first fact in a few commands
Install the SDK. The second line creates a free key (your-name is just a
label for who is calling). Then write the two prices above and read them back with
include_invalidated=True:
pip install korely-memorykorely init --agent --agent-caller your-name --processing-region eu --jsonThe quickstart walks through the first write and the first read. Then ask what the customer pays for hosting. The answer is 55, and 50 is still there, with the day it ended.
FAQ
Questions about agent memory and RAG
Is agent memory just RAG with a database behind it?
It starts with the same retrieval: Korely finds memories by meaning, as RAG does. The difference is the work done when something is written. Korely extracts facts, checks whether a new fact contradicts an old one and, if it finds a contradiction, closes the old fact with a date instead of deleting it. It also keeps each end user in a separate scope. A RAG pipeline on its own stores passages and returns the ones most similar to the query.
Do I still need RAG if I use agent memory?
Yes, if your agent has to answer from a library of documents such as manuals, policies or code. Memory holds what the agent learns about people, accounts and projects. The two sit side by side: passages from your documents and the memory block go into the same prompt.
How does an agent stop quoting a fact that is no longer true?
The store has to know which fact replaced which. In Korely a contradicted fact gets an invalid_at, the date it stopped being true, and stays in the store as history. A default read returns only what is current, and the old value stays available with include_invalidated or as_of.
Does reading agent memory call a language model?
Not in Korely. No language model runs on a read. get_facts is a database query. get_context turns the question into an embedding, with an embedding model Korely runs itself, and assembles the block from stored facts and memories without generating anything. The language-model calls happen when a memory is written.