Why my agents never forget what they did last session
Every agent session ends eventually. The terminal closes, the context window fills up, the machine restarts. None of that is the problem. The problem is what happens the next time that agent opens, and whether it remembers anything about the work it was doing an hour, a day, or a month before.
The mechanism, not the idea
I did not solve this with a vague promise to "add memory later." There is an actual pipeline running today: every agent keeps session notes plus its own MEMORY.md file, and that file gets pushed on every /wrap. That is the command I run to close out a working session, and closing it out is exactly the moment the agent's memory gets written to disk and committed, not left sitting in a context window that is about to evaporate.
I want to be specific about why that detail matters. A lot of "agent memory" pitches describe a system that could theoretically persist state. Mine is described in my own registry as a currently-operating pipeline, dated, documented, and in use. This article you are reading right now was itself produced under that same /wrap and /pause mechanism. It is not a case study of something I did once. It is the thing running underneath the session that wrote this sentence.
Starting cold is a choice, and I chose not to
The other half of session-restart memory is what happens the first time an agent exists at all. You can start it with nothing and let it build history from zero, or you can try to backfill it from work you already did somewhere else. I tried the second path deliberately. There is a real pilot project where I imported historical Claude project conversations directly into a dedicated Hindsight bank, tagged with source:claude-projects, agent:auto-memory-import, and user:mike.
That pilot matters for a reason beyond the tags. It means the memory a fresh agent inherits is not limited to what happens after I flip it on. It can start with a real history of prior conversations already loaded, so the first session with a new agent does not feel like the first session at all. It feels like the fortieth, because in a sense it is.
Why the restart moment is the real test
Anyone can make an agent look smart mid-conversation. The context window is full, everything you said ten minutes ago is right there. The actual test of a memory system is the restart: close the terminal, come back tomorrow, and see what survives. If the agent asks you to re-explain who it is, what project it owns, and what it did last time, the memory system failed, no matter how good the architecture diagram looked.
The /wrap to MEMORY.md loop passes that test because it does not depend on the context window at all. It writes to disk. The file is there whether the session restarts in five minutes or five weeks. And because it is pushed, not just saved locally, it survives a machine getting wiped or an agent moving to a different box entirely.
What I would tell someone building this from scratch
Do not treat session persistence as a nice-to-have you will bolt on once the agent is "working." Build the write-on-close habit in from day one, the same way you would build in error handling. Pick one clear trigger, mine is the /wrap command, and make writing memory a mandatory step of that trigger, not an optional one an agent can skip when it is in a hurry.
And if you have prior conversation history sitting around from before the agent existed, do not throw it away. The backfill pilot I ran proved that a cold start is not actually required just because the agent is new. The history exists, the only question is whether you bother to move it into the store the agent will actually read from on session one.
Session restarts are not an edge case in agent work. They are the default state of the world, every single day, for every agent I run. Building for that from the start is the difference between an agent that grows sharper the longer I use it and one that resets to a stranger every morning.