Cross-Session Memory: Explicit Memory, Automatic Memory, and Three Criteria for Retrieval Injection
Make the agent remember this repo's pitfalls: implement a file-based memory directory, distinguish memory a user writes explicitly from memory the model distills automatically, retrieve by keyword and path and inject only the relevant few entries, and work out exactly what should never be remembered.
Today's Goals
- Design a file-based memory store, and explain how it divides labor with the session log and instruction files
- Implement memory retrieval and on-demand injection, controlling entry count and budget
- Name three categories of content that must never be written to memory, and block them in the implementation
Yesterday's checklist was ephemeral; today's is the opposite. When you finish, scroll back up and tick the three goals off.
Plain-Language Walkthrough
Handover notes: the traps in this repo, written down for the next person
The new hire has worked ten days: reads code, edits files, knows the team rules, and keeps a checklist. Today they clock off and someone else arrives tomorrow.
So the same thing happens a second time: the newcomer runs npm test, finds it is an empty shell, and spends twenty minutes discovering this repository's tests need a different command. Last week's hire hit the same trap and left it in their own head.
Teams that hand over well have a solution: a book of handover notes. Not a diary and not a rulebook, just a stack of short "there is a trap here" cards, one thing each, with who wrote it and when. The next person does not read it through; they pull out the one or two cards when they hit related work.
The difference from day seven's session log is worth stating up front: day seven solved how one conversation continues; today solves how experience passes between different conversations. Restoring a session helps only with the same job, while "tests need a different command" has nothing to do with what you discussed last time.
So the core proposition is one sentence: an Agent has no memory, but you can give it a searchable external notebook. The hard part is not writing things down, it is pulling out only the right few afterwards — and what must never be written down at all.
Interview questions
What problem does an agent's memory solve, versus conversation history and project instruction files?Agent 的记忆和会话历史、项目指令文件分别解决什么问题?
Common in ChinaCommon overseasBasic#agent-memory#context-design🔒 Unlock this chapter to see the answer keys.
How do you retrieve memories so that only the relevant ones get injected, and how would you define relevance?记忆怎么检索才能只注入相关的?相关性判据你会怎么定?
Common in ChinaCommon overseasIntermediate#memory-retrieval#context-injection🔒 Unlock this chapter to see the answer keys.
What must never go into long-term memory, and how do you detect that a memory has gone stale?哪些内容绝不该写进长期记忆?记忆过期了怎么发现?
Common in ChinaCommon overseasDeep dive#memory-hygiene#secret-redaction🔒 Unlock this chapter to see the answer keys.
