DEV Community

Discussion on: My LLM agents forget conversation history when I restart them, how do I fix this?

Collapse
 
nark3d profile image
Adam Lewis •

Where does the halfway state live when you close the terminal, is it in the message list or reconstructed from the repo each time it starts? That distinction decides the fix, because saving the transcript is easy and the plan the agent was carrying is hard. If the plan is implied by the files it has already touched, restarting is re-deriving it. So which one is it?

Collapse
 
izgorodin profile image
Edward Izgorodin •

Both, depending on how the session comes back. Resumed as it was, it is the message list: Claude Code writes the conversation to a transcript file as it works, and a resume restores the conversation with the state saved in it. Resumed from a summary, or compacted along the way, the message list becomes a summary, and the documentation lists what is rebuilt from disk instead: a plan written in plan mode is re-injected, and up to five of the files the session read or edited are re-read, most recently modified first. A brand new session gets neither. It starts from the instruction files, the auto memory index and a git status snapshot, and nothing of the conversation.

Your split is also the line auto memory draws. Its project notes are meant for ongoing work and decisions that cannot be derived from the code or git history, and it skips what it can derive from the codebase. That is where re-deriving from touched files falls short. The files record what the agent did. They do not record the approach it tried and dropped, so an agent that rebuilds the plan from the repo on Monday can propose that approach again.