Files as Memory: Bringing SAG2 to Agent Memory
Introducing SAG-Mem and SAG-Mem-Lite. We compare the cost and accuracy of memory retrieval and explain multi-hop search and date resolution over original conversations.
Paper: https://arxiv.org/abs/2611.33124
Research code: https://github.com/Zleap-AI/SAG-Mem-Benchmark
Hi, I'm Jomy. Today I'd like to share our latest research.
When we released SAG2, our guiding idea was “files as knowledge.” Documents, notes, and code stay in their original files. SAG2 searches them directly when a question comes in and achieves state-of-the-art retrieval without a large language model or embeddings. That made me wonder: if the files hold my conversations with an agent, could a similar approach find the right conversation records?
Today we're releasing SAG-Mem and SAG-Mem-Lite, two memory frameworks based on SAG2.
They demonstrate the idea of “files as memory.” We write the original conversation history to files, preserving the messages and their dates. When the user asks a specific question, the system retrieves relevant conversations as memory.
The cost–accuracy threshold

(The x-axis is logarithmic. On a linear scale, the cost gaps between memory frameworks would be even more apparent.)
These charts compare memory frameworks on LoCoMo and LongMemEval-S. Higher points mean more questions answered correctly. Points farther left mean lower total costs for indexing, retrieval, and answering.
SAG-Mem prioritizes accuracy. It uses a decision model to judge which evidence helps answer a question. SAG-Mem-Lite prioritizes cost efficiency. It uses vector similarity to select relevant evidence at a lower retrieval cost.
The green dashed line marks the cost–accuracy threshold set by SAG-Mem-Lite. Methods in the shaded lower-right region cost more and achieve no higher accuracy than SAG-Mem-Lite.
Mem0, MemOS, Zep, and TDAM all fall in that region in both charts. Lite costs less and answers more questions correctly than all four frameworks on both datasets.
On LongMemEval, which has longer conversation histories, Lite costs less than a tenth as much as passing the full context to the answer model, and it answers more questions correctly. In this comparison, it reduces token use and improves answer accuracy.
The blue dot represents the full SAG-Mem method. We spent more on using a decision model to select evidence, which gave us the highest overall accuracy on both datasets.
Start with the original conversations
The Raw-RAG paper questioned the gains from complex memory frameworks. Retrieving and reranking passages directly from the original conversation logs ranked first in six of seven test settings and substantially reduced ingestion cost. In those settings, additional memory extraction and organization offered little benefit. Keeping the original text and improving retrieval worked better.

(Paper: https://arxiv.org/pdf/2610.30755v1)
For example, a colleague sends a message: “We originally planned to meet on Wednesday, but we moved it to Thursday because Lin is away on a business trip.” At the time, you might only care about the final date. A few months later, you might want to know why the meeting moved. Saving only the final date loses that reason. The original message preserves both arrangements and the relationship between them.
SAG-Mem and Lite also start with complete conversations. They store the original text with its speaker and date. During retrieval, they find clues in the evidence they already have and look for other relevant passages. Information from different conversations can then support the same answer.
On LoCoMo and LongMemEval-S, both SAG-Mem and Lite achieved higher overall accuracy than all the memory frameworks evaluated by Raw-RAG, including Mem0, MemOS, Zep, and TDAM. These results further support retrieving uncompressed conversations directly as memory.
How multi-hop memory retrieval works
One difficulty with memory retrieval is finding related information across several conversations. Take an example from the paper. When you ask “Where does Maya's mentor live?”, the answer is split across two conversations.

Leo is the mentor named in the first passage and the speaker in the second.
With SAG2's multi-hop retrieval, SAG-Mem and Lite can use evidence they have already found to continue searching. This uncovers passages the first round missed and connects information across conversations to support the final answer.
A search using only the original question can find Maya's mention of her mentor, but is less likely to find Leo saying “I live in Kyoto.” SAG2 reads the first passage and uses the name Leo for a second search. The conversation records include the speakers, so the system can connect the two passages.
Vector scoring without a vector database
Whenever SAG-Mem retrieves a batch of passages, it asks the JEV decision model to judge which ones help answer the question, given the evidence collected so far.
A decision model still takes resources to run. For Lite, we wanted to reduce that cost. Keyword search already finds the candidates, so could we rank them another way? I chose a familiar approach from RAG: ranking by vector similarity.

Keyword retrieval finds the candidates, and vectors are used only for ranking. Each round has a limited number of candidates and does not need to search the full set of vectors. A dedicated vector database is unnecessary. We store vectors as ordinary data keyed by passage ID and load them when we need to rank those passages.
At indexing time, an embedding model computes a vector for each passage once. When the user asks a question, we compute its vector once, load the candidate vectors, and rank them by cosine similarity to the question. This removes the JEV scoring cost and avoids deploying and maintaining a vector database.
Resolving dates in code
SAG-Mem and Lite also resolve relative dates programmatically.
Before sending selected passages to the answer model, we use regular expressions to find terms such as “yesterday” and “last month.” The program resolves them using the date the message was sent and appends the result to the original wording.
I moved yesterday and signed the contract last month.
What the answer model reads:
I moved yesterday (2025/05/11) and signed the contract last month (2025/04).

If you ask several months later “What day did I move?”, that “yesterday” still refers to May 11. For the contract, the user only said “last month,” so the program shows April without assigning a specific day. Vague expressions such as “recently” stay as written. We apply the same approach to English terms such as “yesterday” and “last month.”
In an ablation experiment, we held retrieval results fixed and changed only how dates were shown to the answer model. The change improved accuracy on LoCoMo by up to 15.89%.
Next: memory compression
We kept the original texts in this work and got good results without memory compression. Agents often also need higher-level information to understand a task and guide their search for the original text, so compression remains an area we are exploring.
I think a good memory framework should use the simplest engineering methods that help an agent focus on its current task and complete it better at a lower cost.
We're now exploring an approach that differs from traditional memory compression and collecting the remaining experimental data. We'll share the full version soon.


