What are your solutions for agent memory?
Most people agree that, to be effective, ai agents need memory. There is little agreement, however, on how to go about giving AI agents the capability to remember interactions and to use those memories in a way that gives value to future conversations.
One thoughtful comment that is not AI-assisted unlocks the ability to create threads.
56 comments
The answer: it depends. I have used some simple databases with semantic search and sometimes MD files. A lot depends on the task at hand. For example, when I was coding up a data analysis engine, I used a Vespa store with Hybrid retrieval to find past queries and their outcomes. This was given as context to the new query (the LLM had to write a suitable SQL). After the interaction, the entire conversation was sent to another LLM to come up with a "learning". Keeping the memory clean without duplicates was more challenging. After each query, the retrieved answers were logged. A background job processed the retrieved jobs and cleaned up the duplicates / very similar ones and replaced them with a consolidated learning.
For coding (with Codex / Claude) I often use an MD file. Explicitly tell the agent to log/remember details. This can then be (manually) recalled. Another option is to write a skill: for example if I am working with a K8s project a skill to start up or wind down the cluster is wrote down as a skill. I have also looked at memory stores like Hindsight but never used it that much.
Deduping memory and keeping it from drifting out of date has always been the most challenge part for me. Would love to hear more about how you're doing the consolidation / dedupe process.
In the particular case I mentioned, it was a limited scope memory: How did you answer data analysis questions via SQL query construction? Th agents' thought processes are recorded. A replay is initiated offline with the questions the user asked. Initially all queries and learnings are marked as "untouched" (a tag field). Queries are first run and the set of similar queries and learnings are then passed on to an LLM. The LLM then decides whether the learnings are justified and if something is duplicated. The LLM produces a set of queries and learnings. Sometimes learnings are summarized as well.
This works because of the limited scope of the memory. A learning is about two or three lines. A query is also a few lines max. So semantically similar queries and top learnings for each fit well within the context window of the LLM.
The queries and learnings are then moved to cold storage (object store) and erased from the memory database. In their place we have a new set of queries and learnings. Multiple queries may be linked to the same learning. Before adding this new learning to the database, first we look for semantically similar learnings (with a minimum score requirement). These and their corresponding queries are then passed on to the LLM along with the current output (queries + learnings output by the LLM). The iterative process continues until no new query is found with a minimum similarity score. These queries and learnings are added to the memory database marked as "touched". If anything untouched remains, randomly pick one query and start from there.
The touched/untouched field is only used for offline memory processing.
There's fundamentally two different setups for agent memory. It comes down to who’s using the agent.
For agents I run myself, on my machine or on infrastructure I control, I’m happy to give them fairly broad access. The files live in my Brain vault. A file watcher picks up new files and indexes them in Qdrant using Google’s Gemini embeddings.
It handles more than text. When an agent gets an image or creates a file, we save a little Markdown sidecar with the context from that conversation. So when I find the file months later, I can see why it was there in the first place. I index the agents’ inbox messages too. That’s made a massive difference to recall. I can ask why we made a decision six months ago and find the actual conversation.
I call it Inkie and the Brain, open sourced here (github.com)
For a service other people use (and what I use in Inkie Platform (inkie.ink)), I’d go straight to Mastra. If an agent needs to keep track of a long conversation or pick it up in another session, it runs on most dbs and the harness already does a lot of the work I’d otherwise have to build. Its Observational Memory writes notes as the conversation goes and condenses them when they get too long. Mastra reported 83.3% at 100k tokens and 80.6% at a million on BEAM, the long-conversation memory benchmark.
Mastra’s BEAM results (mastra.ai)
I'm going to intertwine 'memory' and 'context' a bit here. I think, with the exception of personal agents, that you don't really need long term session memory for professional tasks.
For development we use a concept called agent docs (plus session logs), so key architecture and feature details are maintain as json files in /agentdocs. This keeps our memory token bill pretty cheap and important decisions are logged and maintained.
For the agents in our platform has we managed trace and context and user input memory as offline tables in DuckDB. This means I can debug them, and ensure they deliver consistent quality output to users.
I run an MCP knowledge server/vault I built and host myself for second brain purposes. The tech is not super complex; it's the config, the knowledge management practices enforced up front by the code that make it work well for me. All my docs are markdown with strict frontmatter - doc status, provenance, etc -- that keeps outdated material from search and browse. I've made it harness-agnostic so I can attach it to Claude, Chat GPT, Open Claw, whatever, and the harnesses behave similarly to one another. I'm turning off any memory functions in the harnesses possible and keeping system prompts super short and serving up the real instructions from the MCP server so I don't have to keep personas in sync across projects and products. So, the models/harnesses are interchangeable, disposable compute now and I don't get locked in to one product. Right now, the knowledge base is mostly tech projects, but I'm starting to experiment with episodic memory within this framework to see if I can get from second brain to second self.
Not an engineer here, so my setup is plain markdown in an Obsidian vault. But it runs my whole job across Claude Code Codex, and what made it work was splitting memory into three layers, each with its own job.
Structural context is kind of a wiki. One md file per topic (say, per client). Who they are, how they work, what we've agreed. It changes slowly. And files are linked, so it's easier to navigate (agent-first)
Historical context is kind of a journal. What happened on August 11th with client X, what they said, what we agreed on something. It may modify the structural context. Also files are linked to the structural context, and even between the historical ones
Memory is the third layer, and the smallest. Only what's live and mine to act on, each item two sentences max, with a pointer to the wiki page or journal entry that holds the real context, plus a few tags (status, priority, a review-by date).
My platform is both a productivity platform, but also a persistent AI presence, a single individual that exists between turns without forgetting you, or itself. Therefore, memory is the highest priority for me. I have multiple levels, but the biggest difference is that I do not use "sessions" at all. My context is built like so:
System prompt and persona profile
Tools, environment context, project data, etc
Facts, user info, insights, small fragments of info maintained by the AI itself
Semantic recall of long-term memory, encoded as individual messages
Recent conversation, rolling window, not a constantly growing session
I use MongoDB as the primary memory store, for the AI-managed memory, and the conversational memory I use Qdrant as the vector store for semantic recall, both for the conversational memory and the AI-managed memory Future plan: A graph database / knowledge graph for generating corpuses of knowledge distilled from the conversation memory
Edit: I don't know why this is marked as AI-assisted. These are all my own words.
re:AI-assisted - Really sorry about that removed the tag and will look into the root issue it was just implemented today so may be a bit trigger happy!
Is there a reason you use two memory stores when MongoDB supports vector search?
Well, the primary reason is that Mongo did not have a mature vector store when I started developing my system. However, even if it had, Qdrant offers many benefits that Mongo doesn't, including simplicity for portability. I can rebuild the index any time I need, from the primary MongoDB, if I wanted to try a different embedding, for instance, without affecting the primary MongoDB.
We dump all the md files into a git repo before memory is pruned or items are deleted so we can always go back and find something later. Once a quarter we scan the git, compress the stuff we are keeping and put it in cold storage. This way we always have an auditable trail of what happened when but we aren't cluttering up the daily ops
If anyone is interested, I have a adaptable agent-brain concept I've been testing for 8 months now, and it's been placed on 4+ assistants with completely different work environments and uses and it fully transforms based around their needs. It's graph/node based with a standard set of tools and basic usage params, but what's cool is, the model(s) / agent(s) develop the environment of the brain over time to their needs.
It's my daily driver at my full time job and holds everything I do reliably, I trust it blindly. (I know, risky, but it rarely has ever let me down, and if it ever does typically a low quality model, not the brain itself. But the new models never have issues.)
Ironically, late for work, I'll add more to this later if people are interested.
I've used Google Sheets, Zapier Tables, AirTable tables, and a variety of DBs to store context. I've also used a few different semantic memory platforms. I only use no/low-code solutions and I've found value in each of these solutions. I'm currently working within a Claude Project and using its embedded semantic memory (Memory) along with Google Sheets.
I try to save and reuse Markdown (.md) files. Context compaction works well for long-running agents. Some models do it automatically, while others require you to explicitly issue a command. It also depends on the task. If a task can be accomplished using a built-in command within a tool, I prefer to instruct the AI to use that command rather than have it figure out how to accomplish the task on its own.
What my agents should remember matters more than how they remember it. I use several layers, each with a separate job.
Canonical reference docs. Each machine has its own authoritative document on how to build, configure and recover its agent stack. Agents read it before doing any work. When they change something, they update the document in the same session. Each machine owns its document, so two agents never edit the same file. These docs do most of the work, and the other layers support them.
Git-backed journal. A file tool that overwrote files by default kept silently truncating one reference doc. Every reference file now lives in a local Git repo that commits every five minutes. A guard blocks any write that would sharply reduce a file’s size or that contains something resembling a key. A nightly job reviews the day’s changes and proposes edits without applying them. I approve or reject each edit. At the start of a session, agents load a small index instead of whole documents.
I deliberately chose not to delete unused memories. My backup and restore procedure is rarely read, but I want it available when I need it.
Ambient capture on the Mac. Omi, Plaud and a screen-memory tool record what I do. Nothing loads by default. Agents use MCP search tools to query the recordings when they need them to answer a question. Once a day, an agent summarizes the day’s work in a short, structured note in an Obsidian vault. That note becomes the long-term record.
Wiki checks. The Obsidian vault compiles into a wiki. A weekly job compares wiki pages with one another and with the live system, then flags conflicts. Most flags turn out to be bugs in the checker, but the real conflicts it has caught make the checks worthwhile.
Agent handoffs. Agents on two Macs and a few agents from other vendors coordinate through a synced vault and per-agent mailboxes. Anyone can write to an agent’s inbox, but only that agent writes to its outbox, so you know which agent wrote an outgoing message. Nothing clinical or secret goes into anything that syncs.
If you’re starting out, write the reference doc first. An agent does better reading one accurate page than searching a thousand stale ones. Retrieval and embeddings come later.
I’m a cardiologist, so one rule takes precedence: patient information never enters agent memory. Capture tools are blocked from clinical apps, and I check for anything that slips through.
Our setup is a bit different. Most of our agents don't code, but manage projects. So some of the memory lives in the session itself and we end up with very long sessions (that compact as they go along). We also have MD files on the server with playbooks by topic, and a Context Engineer agent who keeps streamlining them as well as skills and other system-wide files.
There is a great discussion with lots of approaches people are sharing in the gist from karpathy (gist.github.com). This sparked a lot of ideas and approaches but so far, there is also no convergence on how to solve it. In addition, the harnesses started to introduce their own take with things like memory (code.claude.com).
We are instructing our agents to either write markdown files with obsidian frontmatter for easy organization and retrieval or we ask them to update our company wiki (Confluence).
I'm super frustrated that the different Claude surfaces don't share a common memory, so I'm building my own simple solution as a plugin that can be used by Claude.ai, Claude Code and ChatGPT. It's basically just a bunch of markdown files in Git at the bottom, but it runs in Cloudflare workers by default so it doesn't rely on any of my machines, and I back it up at home periodically just in case. Just about done - we'll see how it goes, and I'll make it open source if I end up using it.
In my
AGENTS.mdfile I have a section named Project knowledge base that tells the agent to read and maintain the md files inside a specific folder where all new durable project knowledge has to be written at the end of the session. It is very effective for coding work. There is no issue of stale information because agents are quite good at updating it.I've been using Fresh recently, as a kind of orchestration layer to keep me organised as I test out different agents and models. It has a "Code Tour" feature that I have the agent write at the end of a session. Then when I open things again, I have whatever agent/model combo I'm enamoured with that day, read in the the last tour. Simple and it seems to work well enough for the things I'm working on.
https://github.com/somayaj/fry - built this for agent memory if useful.
There was a great article in the TLDR Newsletter a few months ago: graph based agent memory (newsletter.systemdesign.one)
I think the ICM folder system is a really good concept YouTube (youtube.com) because of the simplicity and usability of .md files.
We use a persistent Markdown state file as a handoff document for each major project. After several years of working with AI on long-running technical and research projects, I’ve found that maintaining project continuity is an engineering requirement. Remembering conversations is a convenience and a separate problem.
What the state file records:
Current project status and verified results.
Architectural decisions and why they were made.
Failed experiments and rejected approaches.
Unresolved issues and dependencies.
Specific next actions and a dated changelog.
We distinguish between what has been verified, reported, decided, planned, blocked, or superseded because an agent can remember something accurately and still be wrong about its current status.
At the start of each session, the agent checks the state file against newer evidence, reconciles any differences, and continues the work. The file is updated after meaningful work.
Agents still occasionally skip this process, and maintaining the files takes discipline. Even so, the process reduces repeated work, helps keep track of decisions, and reduces the tendency to mistake planned work for completed work.
I don’t necessarily need the AI to remember every conversation. I need it to know where we left off, why we’re there, and what evidence supports that understanding.
AI-assisted writing, based on firsthand experience.
Tbh it's like the hardest question to answer properly. You always to chose between quality, cost and quantity of things you want to keep in memory. I went from storing a lot of things to resetting everything and going very minimal. For now I like it this way. Also I think for long living agent, a tensor-based memory is the best compromise between quality and accuracy.
My memory system serves the diary I described in the building thread. Its three stores differ in who may write to them.
Rebuilt by the machine. A private git repo holds 287 entities extracted from my mail, messages, calendar and notes: 130 people, 42 companies and the rest mostly places and concepts. Each entity has aliases and dated citations to its sources. The system ranks who is active now using recency, which decays with a 60-day half-life. Relations are typed, including
distinct-fromto keep two similar names apart.Corrected by me. An overrides file has 44 entries so far, covering names, types, aliases and blurbs. My corrections take precedence over what the model inferred and survive every rebuild.
State. Open to-dos live in a JSON file that the rebuild never touches. Every run commits the file (197 commits), so git shows when an item appeared and when it closed.
The diary follows this rule: "Do not invent facts beyond what the brain says. The blurb is your factual anchor; don't extrapolate." If the blurb says developer, the note can't say lead developer.
What interests me most about your architecture is how you separate human overrides from machine-generated knowledge. How do you handle newer source evidence that contradicts an existing human override? Does the system flag the discrepancy for review, or does the override remain authoritative indefinitely?
I've independently been working toward a similar separation of machine-generated context, human authority, and persistent operational state. One problem I've encountered is temporal validity: a memory can be accurate when recorded but no longer be a sound basis for a current decision.
I've started using explicit state classifications—verified, reported, decided, planned, blocked, and superseded—alongside dated project handoffs and source evidence. My goal isn't necessarily to make agents remember more. I want to prevent them from acting on stale conclusions, overriding established decisions, or repeating completed work.
We created Rust-based solid pod trio's (lww, blob, and grow only) for our AI assistants and now we're making Aurora Recall for memory.
Eric, Aurora Recall got my curiosity going this morning, so I started reading some of your other posts. The Council and your Known Footguns catalog were... particularly interesting.
We've arrived at some surprisingly similar practices over the last few years working with AI on engineering and research projects.
I'd be curious to hear where you're taking Aurora Recall. Is it something you eventually intend to release independently of UCOS? I would enjoy comparing notes.
The direction is pod trios to replace app databases and to be the "brains" of our AI Assistants. Capability grants seemed the best approach. We had originally planned to use CSS (Community Solid Server) but it there was no sync and no messaging so we built our own and Rust is the the majority of our stuff. Definitely interested in comparing notes, let me know
I am exploring a setup where project memory survives swapping AI models, and each part of the system controls what an assistant can and cannot change. What led you to three pods? I am curious though, where the authority to accept or reject an assistant’s update lives in your design once those pods start syncing.
Using a different CRDT for each kind of data makes a lot of sense, and a user-owned pod is a strong starting point for assistant memory.
When two assistants write different values for the same fact, does LWW keep the later value, or does Recall see both and decide which to use?
How does a user delete something from a grow-only pod, whether they say "forget this" or want to remove a password they pasted by mistake? Is the item removed from every replica or kept as a tombstone?
Does each memory record which assistant and conversation it came from?
What will Recall add on top of the pods: extraction, ranking, decay?
I'd love to follow along when Recall ships.
I started building 3ngram (github.com) at the beginning of the year because I was frustrated with context rot in .md files and with agents missing the brief I’d given them. Maintaining CLAUDE.md, AGENTS.md and other .md files, along with GH issues, specs and the like, had become a second full-time job.
3ngram is an MCP server, so any agent can connect to it, read from it and write to it. The small dashboard mainly serves as a control panel and provides an overview. Memories have types, including decisions, commitments, blockers, facts and preferences. Nothing gets overwritten: when a revision replaces a memory, the old version stays readable in the audit trail. Commitments stay open until they’re resolved.
Every Claude Code or Codex session starts with a briefing on the project’s overdue commitments, stale items and recent decisions, so the agent picks up where we left off. I can’t really work without it anymore. My account has around 9,000 active memories, 850+ superseded memories and more than 1,700 resolved commitments.
The most useful thing I’ve learned is how much easier retrieval is than getting agents to write things down and follow up. When I checked which open commitments my agents had seen in their briefings, I found that only a handful had been updated or closed during the session. I keep working on that, and it’s improving week by week. I’m also testing 3ngram against LongMemEval, and I reproduced the paper’s BM25 baseline.
3ngram is open source (Apache-2.0). You can self-host it with docker compose or use the hosted SaaS at 3ngram.ai. I keep extending it based on my own use and as new models and tools come out.
How are you getting agents to write down the relevant parts? The most interesting approach I’ve seen so far is chicagobuss’s: recording everything and slicing it afterwards.
I literally just created a GitHub repo to collect all the md files scattered around my machine. Your app is overkill for me at the moment, but I'll keep an eye on it for when my workflow becomes more complex. Open source ftw!
By the way, when did md files stop being enough? Also, what do you mean by "context rot"? Sorry for all the questions, but I'm just getting started with this. 😅
I still use Markdown state files, but I had to keep reminding the agent to read the file at the start of each session and update it when something materially changed. I ask the agent to record the evidence behind a decision or a closed commitment so the next session can check what actually happened. The agent still sometimes skips that step. Have you found a way to get agents to make those updates consistently after they’ve read the briefing?
So glad you asked! I've been working on this pretty continuously ever since I started recording everything my fleet does in tracker (github.com).
I call it 'Thinker' and it's a real-time, self-organizing memory engine that watches my coding agents' actions, automatically slicing meandering conversations and thinking marathons into coherent, topic-focused "turnsets" and clustering them into an interactive knowledge map.
Its killer use-case is curated context injection: by pulling the exact, most recent turnsets that match a prompt, it lets a modest local LLM punch like a frontier model with up-to-the-minute awareness of my work.
Beyond supercharging "fleet search" prompts for me, it also gives every agent in the fleet shared cross-repo memory—so one agent immediately benefits from a bug or design decision another solved minutes ago—while letting me visually navigate and run cited, deep-linked searches across months of activity across tens of thousands of knowledge nuggets.