Why Your Agent Needs Memory, and How to Organize It

Your agent’s personal memory is not what it already knows. It is only what it could not have guessed.The curve is everything the model already brought. The one point off it is the only thing worth writing down.I am Volodymyr Vreshch, and I keep a personal memory store for my coding agent on one…

Your agent’s personal memory is not what it already knows. It is only what it could not have guessed.The curve is everything the model already brought. The one point off it is the only thing worth writing down.I am Volodymyr Vreshch, and I keep a personal memory store for my coding agent on one machine. Today it holds 181 topic files behind a 134-line index. Almost none of it is knowledge.The agent already knows how Express middleware works, how a Playwright test is structured, and what a Dockerfile does. It has read more of all three than I will in a lifetime. Every line I have written down exists for the opposite reason: it is a place where my world does not match the field average.The deploy verifier blocks the release when a check cannot run, on purpose. The release train’s self-approve gate reads .status and not .conclusion, which cost me an afternoon before it became a line in a file.That is the shape of the thing. Agent memory is not a copy of what the agent knows. It is the delta, the part left over. What follows comes out of running that store, not out of reading about memory.Memory is the one part of the agent that everyone agrees you need and nobody has specified. So this piece has two halves: why your agent needs a memory, then how to organize one. The how half has four parts: keeping it simple, what each memory unit and its store must be, which storage meets that, and what living with it looks like.Agent memory is not human memoryThe instinct is to reason by analogy: I remember things, so the agent should remember things.The analogy breaks at the first step. Human memory has to hold the average and the exception, because a person starts empty. A model starts with the average already loaded, at a scale no individual has. Telling it what middleware is does not add information. It adds tokens.And tokens are not free, which is the part most people get wrong. Context you did not need is not neutral. It is negative. One study measured how often a model called an API correctly. When the model got documentation for APIs it already knew well, and that retrieval was imperfect, its correct-call rate dropped by 39 percentage points.The same documentation, fetched for rare APIs the model did not know, raised accuracy by nine points. Same content. Same pipeline. Opposite sign.That changes what a memory file is: a diff against what the model already assumes. Every line repeating a well-known convention competes with the one line that matters. Attention is the scarce thing in the room.Write down only what the model could not have guessed.Apply that test to real context files and most of what teams put in them falls out: naming conventions, “prefer composition over inheritance”, the standard folder layout. That is exactly the field average, the part a linter owns, and the model already has. The lines that actually carry weight are usually the ugly ones: the workaround, the dead path, the thing that is true here and nowhere else.My own store is 181 topic files and 3,697 lines, or 3,831 counting the index. Not one line explains what middleware is or how a test is structured. The model brought that. The lines I delete are the ones that drifted into explaining a well-known tool, because the model already had them and they were costing tokens on every request for nothing.The cheapest memory is the memory you do not needIf memory carries the delta, then the size of your memory depends on how far you stray from the common pattern. Follow the usual architecture, and you owe the agent almost nothing, because it already knows it. Invent your own module system and every rule in it becomes a line you have to write down, keep true, and pay for on every request.You can feel this without a benchmark. Ask an agent for something in a mainstream stack, and it goes and builds. Ask for the same thing in a niche language or a custom internal framework, and it stops, guesses, or asks. Closing that gap means carrying the context yourself: writing it, versioning it, maintaining it forever.I do not have a clean A/B for this, and I will not pretend otherwise. The papers in this piece back the mechanism. My own files back only the practice, and I am not offering the second as proof of the first. New work in ordinary stacks goes fast. Work in big old systems, where most of the context was never written down, goes slower, sometimes slower than doing it by hand.So architecture choices are now memory choices. Pick the boring, widely used pattern, and you take on nothing you would have to maintain forever.Every deviation from the common pattern is a line you will have to write down, and keep true, forever.The custom path costs more on every future request, not only on the one that created it.The hard part is keeping it simpleThat is the why. Here is the how. The part that kills memory systems in production is not forgetting. It is accumulation.Value grows slower than size. Twice the memory is not twice as useful, because the noise piles up faster than the signal. Past some point, a bigger store answers worse than a smaller one did, even on the questions it was grown for.Conflict grows faster than size. Every new fact can contradict every fact already there, so possible clashes climb much faster than files do. And a contradiction costs far more than a gap. A missing fact leaves the agent unsure, and unsure is fine: it asks, or it fails where you can see it. A contradictory fact leaves the agent confident and wrong. Nothing in the loop looks broken, so nobody catches it.Worse, most memory products cannot see that conflict. Vector similarity sees two sentences about the same topic. It cannot see that one says yes and the other says no.Value flattens, conflict keeps climbing, and past some size, your memory system is making your agent worse.Nothing fires at the crossing point. You find out later, because the answers got confidently worse.Memory does not fail loudly. It fails by getting confidently wrong while every query still succeeds.So the hard part is not piling things up. Every product I have tried will happily do that for you. The hard part is staying small and still being enough. That takes deleting, and deleting means judging your own old writing.The reflex is to add structure. The pile is a mess, so impose a taxonomy: hierarchies, categories, graphs, formal knowledge structures. This reliably makes it worse. In one 2026 evaluation, someone added depth to an on-demand context index. Same model, same test harness. Accuracy fell from 0.91 to 0.64.A thirty percent drop, bought with nothing but structure. Flat beat hierarchical everywhere it was tested. Elaborate structure does not fix complexity. It is a second complexity on top of the first, and now you maintain both.So organizing memory is less about drawing a better diagram than about setting a bar each line has to clear, and a store that makes clearing it cheap.Four tests every memory unit must meetThe bar goes on the unit, not on the system. Four tests, and I hold every file in my store to them. On a team, they are also what a reviewer checks.Simple and dense. Seed information only. No sentence that exists to sound complete. If a line does not change what the agent would do, it is decoration, and decoration is not free.Non-conflicting. No two facts that cannot both be true. This is the one that requires active work, because conflicts build up slowly and never on purpose.Useful, measurably. Memory does not make an agent smarter. It makes it faster and cheaper at the same quality. Not better answers: the same answers, without the rediscovery. If a file does not visibly cut time or tokens on a real task, it is not earning its maintenance cost.Classified. A checked fact, an assumption, a preference, and a rumour must not look alike. Mine carry the kind in the filename: 117 reference_ files hold checked facts, 50 feedback_ files hold standing rules, 14 project_ files hold state that expires. You know what a file claims before you open it.One published result looks like it kills the third test, and it does the opposite. A study from ETH Zurich compared repository context files against having none at all. The result: no general gain in task success, and over twenty percent added to inference cost. The machine-written files even scored slightly below having nothing.Read it with the delta rule, and it stops being a counter-result. A file full of average knowledge is exactly what the rule predicts: real cost, no gain. The finding does not say context files fail. It says the ones that only restate the average fail, which is most of them.So the discipline is not writing. It is deleting, keeping every line dense, and never letting two lines contradict each other.Addy Osmani made the same point from the maintenance side this August: agent files rot as models improve, so prune and rebuild them now and then instead of adding forever. A memory that only grows is a memory on a timer.Then slice what survives by task, the way your own memory does. What you load to write prose is not what you load to debug a build.You do not need one memory. You need the smallest correct slice for the task in front of you.Three requirements your store must meetThose four tests say nothing about where the files live. That is the other half of organizing.I did not pick a storage format because I judged it best. I noticed something else instead: the tools already reading the markdown in my repos agree on nothing but that, and I went looking for why.AGENTS.md is a plain markdown file at a known path, read by more than twenty tools whose vendors compete on everything else. No memory API has been implemented twice by competitors.A survey of production coding agents found seven of them landing on the same design without talking to each other: one small markdown file always in context, plus a bigger archive on disk, opened when a task needs it. None reached for vector search.No two of them read the same benchmark, yet all seven hit the same three requirements.You can search it with nothing installed. People hear “search” and think semantic search, which is not even the common case. Anthropic’s own memory tool has view, create, replace, insert, delete, and rename. It has no query at all.It expects the agent to list a directory and read what is there. If your memory only works when the index is built, the embeddings are fresh, and the vendor is up, you have put a weak point in front of your context. It has to keep working when all of that is down.You can change it with a human watching. Self-updating memory is where the field is getting hurt right now. One production audit of 10,134 auto-extracted entries found 97.8% of them were junk. In a separate study, letting a model write its own successful runs back into memory scored below having no memory at all, on four agents out of four.Memory that writes itself does not drift politely. It drifts confidently. So a change to memory has to be reviewable, and reviewable means you can see it as a diff, reject it, and undo it.You can keep it alive with the tools already open. Memory systems rarely die of corruption. They die of neglect. Someone writes the file once, nobody touches it again, and it drifts until it is lying.A write-up of one 2026 study found half of all context files were never updated after the first commit. The 6% that keep getting revised belong to the people who say the agent actually helps. My own files match that shape: the ones I have rewritten still earn their place, and the ones I wrote once are the ones I delete. Upkeep has to work in the editor, the search and the version control you already run all day.That is the whole specification. Everything after this is which storage meets it.Why markdown files in git meet all threeHere is the honest framing: files are not my discovery. “Markdown beats vector databases for agent memory” has been argued on Medium at least six times in the last year.It hits Hacker News often enough that the threads reliably produce some version of “a whole lot of text to say just use text.” If you read this as me arguing against everyone else, you have read the wrong article. What the conversation is missing is the why.Three vendors selling memory databases published against files within three months. The two vendors shipping the agents had already chosen files. I have nothing to sell in this fight. What I have is a folder.What the field actually storesWhat a system stores decides everything downstream.Mem0 stores an LLM-extracted sentence plus its embedding, one row in a vector index. What you get back is not your document but an extractor’s paraphrase of it, and you cannot open it.Zep stores a typed edge in a graph that tracks two timelines per fact, so every fact carries a validity window. Corrections happen by replacement: the old edge is marked dead, not rewritten.One vector-native memory startup ran vector archives for years. Then, in early 2026, it made a tree of markdown files in a git repository the default store for its coding agents, one commit per edit.Anthropic ships a memory tool that is nothing but file operations on a /memories directory, executed by your own client. It's hosted, still-beta Memory Stores API names things by path, filesystem-style, and settles concurrent writes with a content hash: git's data model with an HTTP skin.The consumer assistants store a summary you only ever see rendered. As of September 2026, none ships a documented machine-readable export.Line those up and the real split turns out to be readable versus not, not “files versus databases”. Every option except the file-shaped ones shares one property: you cannot diff your memory between two points in time. You correct it with a toggle, not a commit.Three ways to store one fact. Only one of them survives being reopened.Both sides are shipping, and both have a pointMatrixOrigin argued in March 2026 that static markdown decays and enforces nothing. Five weeks later, Mem0 published “Your AI Agent’s Memory Is Just a File? That’s the Problem”.Their argument: flat files repeat the pre-database mistakes of the 1970s, with no semantic search, no temporal reasoning, no concurrent-write safety, and no forgetting.In June, Zep published “Markdown is not agent memory”, whose sharpest line is genuinely good: “A markdown file records what is written, not what it replaced or why.”Meanwhile Anthropic’s own coding agent keeps its memory as plain markdown on disk. Windsurf’s documentation quietly tells you to move anything you want to keep out of its own memory store and into markdown in version control. Notice who is selling what.And the database vendors are right about two things. Vectors own the case where your words and the note’s words do not overlap. You ask for “that thing I said about being burned out,” and the note never uses the word burnout. Only an embedding closes that gap, at the same speed over millions of rows. Grep cannot find what you cannot name.Graphs own time. Only a fact stamped with a start and an end can answer “what did I believe last Tuesday, and what replaced it?” A similarity score has no opinion about which of two contradictory facts is current. On the temporal questions of one long-memory benchmark, a third-party rerun puts the graph system at 63.8% against the vector system’s 49.0%.Files lose on both counts.The evidence, with its caveatThe retrieval results of 2026 went the other way from what the field expected. Agents searching a plain pile of files with grep, find and file reads beat every keyword, embedding, and reranking baseline they were tested against.On one agentic-search benchmark, dropping the embedding retriever and letting the agent read the files moved accuracy from 69% to 80% and cut cost by nearly a third. A separate study of long-term memory questions found plain keyword search beating semantic search in every inline tool-calling setup it tested.But once results came back as files, the ordering flipped for half the test pairs. The questions rewarded finding the literal thing: an exact date, a count, an identifier, an error string.The caveat comes from the agentic-search paper, the first of those two, and I will not bury it. Grow the pile from 100,000 to 400,000 documents and the same approach falls from 80% to under 40%, with three times the tool calls. Grep works inside an envelope, meaning a size range, not as a law. Inside it, it wins on quality and cost. Outside it, it falls apart.So the honest question is which side of that envelope you are on, not which system wins. My entire store is 181 files. The agentic-search paper reports that this collapse starts somewhere between one hundred thousand and four hundred thousand documents, so my store is hundreds of times smaller than the floor where trouble begins. LinkedIn’s production memory system is not, and I am not arguing it should use markdown.Grep wins inside an envelope. My 181 files sit hundreds of times below the floor where it breaks.Where files win, and where they loseMeasure the candidates against those three requirements, and Markdown files win on all of them, at almost no cost. Grep is the fallback. A change is a diff, and in a repo, a commit you can undo. The upkeep tools are already on your screen.Two things come free on top. Contradictions are visible, because two clashing facts are two lines of text and not two float arrays. And the format you store in is the format you export.Now the trade-off, which I would rather name than hide. Files lose to embeddings when you need fuzzy recall over a lot of documents. The answer is to put the index on top of the files, rebuildable any time, instead of in place of them.Basic-memory does this with SQLite, memsearch with Milvus, Karpathy’s compounding-wiki with an index page and no embeddings at all. When the index is the storage, you give up inspection, diffing, ownership, and portability to get recall you could have had anyway.If you cannot grep it, diff it, and delete a line from it, it is not your memory. It is somebody’s cache of you.How I organize minePrinciples are cheap. Here is the running system, today.A layered pointer, not a manifesto. The root file the agent reads first is 21 lines. It is a map: three top areas, one line each, pointing at the deeper file. One level down, the projects file holds what is genuinely mine. Which repo is live and which one died in a rename. The versions I hold everything to. The communication rules I want obeyed. Twenty-eight of these sit across my projects tree, all written by me, and each loads only if the work goes there.A store the agent writes, and I approve. Next to that sits the auto-memory: 181 topic files behind the 134-line index. At session start, only the index loads, and a topic file opens when a task reaches for it.The rule for what goes in. Only what the model got wrong, or could not have known. Not rules I guessed I would need. Real failures, written down after they caused a problem. Three of them, in their real form: the live web repo is a different directory from the one the old docs name, so check the git remote before editing. Post-deploy pruning is best-effort because concurrent deploys race the lock. Never use an em dash. None of those can be read off the code, and none are in any model’s weights. That is the whole admission test.Grouped by task, not by topic. My store is sliced the way the work is. A design task and a deploy task need different context, and mixing them only dilutes both.A knowledge layer that is mine, not the agent’s. Specs, decisions, plans, and research live in Obsidian vaults, about seventeen hundred markdown files the agent can read and I write. Keeping them apart matters. The agent’s memory is what got left behind by the work. The vault is what I meant to do. Merge the two and the store starts lying about what was decided.Layers for loading, not for reasoningCount those levels, and you get four. That is the depth the earlier 0.91-to-0.64 result argues against.What the study varied was depth, not whether an index existed. Its best setup was a flat per-task index that the agent reads in one shot before deciding what to open. That setup nearly doubled accuracy against raw navigation, at about half the cost. Accuracy only collapsed once the index grew branches that the model had to walk down, guessing which one held the answer from labels alone.My index is the flat kind. It is exactly one level deep and read whole at session start: 134 lines, roughly a line per topic, each naming the files it routes to and summarising them in a clause. There is no branch to guess. It is a short routing table I maintain by hand, not a taxonomy the model has to reason through.It is also allowed to be imperfect: eleven of the 181 files are not listed at all. Every topic file under it is small, flat, and read whole, and a layer opens because the work moved into that area, not because a query went looking. That is progressive disclosure.The test is simple. If the model has to guess which branch holds the answer from labels alone, you built a tree, and you will pay the 0.64. If it reads the whole index and opens a file by name, you built a loading order.Structure is for deciding what to load. It is not for the model to reason through.Only the touched path loads. The rest of the tree costs nothing, because it is never read.The safeguard, because self-written memory driftsThe agent proposes, the write shows up as a diff, and I accept it, or I do not. The files that live in repos carry their own history, so “why does it believe this” has an answer you can read. No vector store or vendor memory page can answer it at all. A memory nobody reviewed is a rumour with a filename.Once in a while I do the boring pass and delete: lines that were true in June, files the model has since learned on its own, rules that a better rule replaced. The store shrinks more often than people expect.For one person, that is a habit. For a team, it is a pull request: memory files live in the repo, a change to them gets reviewed like code, and nobody’s agent quietly learns something the team never agreed to.All of that is plain markdown on my own disk. None of it needs the assistant that helped write it. When a better one ships next year, I point it at the same folder and keep going.So the organization fits on a card: four tests for every line you keep, three for the place where you keep it, and a human between the agent and the file.If you want to know where you stand, it is one edit away. Open your project’s context file, whether that is CLAUDE.md, AGENTS.md, or whatever your tool reads, and delete every line the model would have guessed on its own.I cut half of mine. Run your next real task against what is left and watch whether anything actually got worse. Then, the next time the agent gets something wrong that it could not have known, write exactly one line, and review it like code. That is the discipline. It does not scale by adding more.The agent already knows the average. Your only job is the delta.This story is published under the Generative AI publication. Connect with us on LinkedIn and follow Zeniteq to stay in the loop with the latest AI stories. Let’s shape the future of AI together!Why Your Agent Needs Memory, and How to Organize It was originally published in Generative AI on Medium, where people are continuing the conversation by highlighting and responding to this story.

Source: Generative AI Pub — Published — Category: Image AI

🔗 Read full article on Generative AI Pub →