Don't rush to put Agent memory into a vector database—first look at what is lost after compression
5 articles explain Agent memory using everyday analogies. The core comes down to four things: write, select, compress, isolate. But compression is not lossless. Summaries compress away the places where the user corrected it, so it will make the same mistake next time. One netizen's approach is worth copying: keep a separate section for correction records.
Many people, when they first hear about Agent memory, immediately think of grinding through papers or setting up a vector database. In practice, it is not that complicated.
Someone put together 5 articles. Their common thread is that they all use everyday analogies and plain text files to explain things, without beating around the bush. In Lance Martin's article, the model is compared to a CPU and the context window to a RAM stick. A few hand-drawn diagrams group memory approaches into four actions: write, select, compress, isolate. This classification basically covers all later discussion.
First distinguish setting rules from accumulating experience
The official Claude Code documentation separates two things very clearly. CLAUDE.md is the rules you write for the model: build commands, code conventions, project structure, and so on. MEMORY.md is experience the model accumulates itself, coming from places where you corrected it.
The former is loaded every session; the latter only loads the first 200 lines or 25KB of the index. The documentation recommends that a single CLAUDE.md not exceed 200 lines. The reason is practical: the longer the file, the more context it takes up, and the less obedient the model becomes.
This approach is fully transferable to AGENTS.md in Pi or Codex.
Compression is not lossless
When a session gets long, the history does not fit, and the Agent triggers compression. Pi's approach is to keep the raw messages from the most recent 20k tokens—roughly 5 to 20 turns under the default configuration—and hand earlier content to another LLM request to summarize into a summary.
Two details are worth remembering.
First, compression breaks the prompt cache. Before compression, it is system + tools + old history + recent messages. After compression, it becomes system + tools + summary + recent messages. The recent messages themselves have not changed, but the part before them has changed from old history to a summary. Starting from the first changed token, everything after must be recomputed.
Second, the summary filters and rewrites information and does not guarantee verbatim restoration. If code state is lost, you can recover it from git. If places where the user corrected you are lost, it will make the same mistake next time.
A netizen in the comments added a fixed instruction to the compressor: list in a separate section the places in this passage where the user corrected me. He said he had just compressed once today, and that section was empty—which counts as a result too.
Another netizen's approach is to reserve fixed slots for "what must not be changed" and "what has not been finished yet." Someone else suggested that after compression you should not just continue directly; first replay the goal, the files already changed, and the failures not yet passed. If any item is missing, stop hard. A shorter summary does not mean the task is still there.
What the data says
In Anthropic's evaluation of 100-turn web search, clearing stale tool outputs and pairing that with a local memory folder saved 84% of tokens, while accuracy actually rose 39%. Using context editing alone also gave a 29% improvement.
Another example comes from Anthropic's new article in November. They had AI play Pokémon. The model created 413 files at random, and its performance lost to a version using only 9 strategy files. Accumulating too much memory actually creates clutter, and it still needs to review and correct errors in the background like a person sleeping.
A vector database is not the first step
The Claude Agent SDK article is specifically aimed at unloading burdens for beginners: organize the directory structure well, let the model use grep to browse local files on demand. Accuracy and maintainability are often higher than forcing vector retrieval.
If you just want to use the tools smoothly in daily work, these three articles are enough: Lance Martin's, the Claude Code documentation, and Anthropic's new November article. If reading English is tiring, throw it to AI to translate and read. After reading, streamline the rule files you have on hand—it is more useful than randomly installing memory plugins.
5 original articles:
发布时间: 2026-11-30 01:29