How do you give AI agents memory across sessions?
By storing each kind of knowledge in the right place, and turning the important lessons into rules that run.
A fresh agent inherits nothing from the last chat. I use four places. A project wiki for architecture, decisions and history. Repository rules for the failures every agent must read. A memory service for preferences and lessons across sessions. And hooks, which inject context or enforce a rule automatically.
They are not equal. The code that runs and the project’s written rules outrank summaries, the wiki and remembered context. Memory helps an agent get oriented. It does not overrule the system.
The strongest form of memory is enforcement. A lesson written as a test, a permission or a hook does not depend on anyone recalling it.
Lessons that use it
- 23New agent, same old mistakesA fresh agent inherits nothing from the last chat.
The ruleDecide where each kind of knowledge lives, and which source wins when two disagree.
- 24Scar tissueThe same mistake cannot happen silently twice.
The ruleAfter every failure ask where the lesson must live so that it cannot be skipped.
- 25House rulesA skill turns an instruction I keep repeating into something the agent just does.
The ruleWhen you catch yourself typing the same instruction a third time, package it.