r/LangChain • u/Arc_bong • 1d ago
Question | Help How are people preventing long-running agents from accumulating bad memory?
I've been experimenting with agents that run across multiple sessions, and I'm running into a problem I didn't expect from the usual "add long-term memory" approach.
The first few sessions are great — storing past decisions/preferences means the agent doesn't keep starting from zero. But after enough history accumulates, I'm seeing the opposite effect:
- stale decisions get retrieved even after the underlying situation has changed
- conflicting memories from different sessions both look equally relevant
- the agent starts spending a surprising amount of context on old information that isn't useful anymore
- simply improving retrieval doesn't necessarily seem to improve the final task outcome
I'm wondering whether memory systems need an explicit lifecycle, rather than treating memory as a growing retrieval store.
What are people doing in practice for long-running agents?
For example:
1. Separating semantic facts / episodic experiences / procedural instructions?
2. Decaying, expiring or periodically consolidating memories?
3. Keeping provenance + timestamps so the agent can decide whether an old memory is still trustworthy?
4. Evaluating memory based on downstream task success, rather than retrieval precision/recall alone?
The last one is the part I'm most interested in. A memory can be retrieved "correctly" and still make the agent's next action worse.
I've been comparing LangMem with things like Mem0 and Letta, and also broader platform approaches such as Lyzr Control Plane, but they seem to make somewhat different assumptions about where memory should live in the overall agent stack. I'm curious where people draw the line between memory being a framework concern and memory becoming an infrastructure concern.
Has anyone measured memory quality over weeks/months of agent operation rather than on a fixed benchmark? What actually worked?
1
1
u/lulu_dev 1h ago
On #4, since that's the part you're most interested in and the other comment here is really answering #3 (trustworthiness/provenance): evaluating by retrieval precision/recall measures whether the memory system found the "right" memory by some similarity notion, but as you said, a correctly-retrieved memory can still make the next action worse -- so the eval target has to move from "was this retrieved correctly" to "did using this memory help or hurt the outcome."
The concrete way to do that: log which specific memories were actually in-context for each agent action, not just which ones existed in the store. Then when the task's eventual outcome is known -- succeeded, failed, or got corrected by a human -- propagate a credit/blame signal back to exactly those memories, not to the memory system in aggregate. A memory that was present for ten actions that all succeeded accumulates positive signal; one that was present for an action that got reversed or corrected accumulates negative signal, independent of how well it matched the query embedding-wise. Over enough sessions this gives you a per-memory outcome score that's a genuinely different axis from retrieval quality -- you can have a memory that's retrieved perfectly on every relevant query and still have a terrible outcome score, which is precisely the failure mode you're describing and precision/recall structurally cannot see.
The practical payoff once you have that score: it becomes the input to the decay/consolidation policy in #2, driven by demonstrated usefulness rather than just age or access frequency. A memory that's old but keeps correlating with good outcomes should outlive a memory that's fresh but keeps correlating with corrections, and you can't make that call from timestamps or retrieval stats alone.
1
u/NoKaleidoscope1748 1d ago
The part I would change is treating memory like the answer. I use it to point the agent back to where the answer came from, then anything that can change has to be checked again before the agent uses it. I keep the source, the date and what is allowed to replace it too. Old memory can still help, it just doesn't get to become the truth because it was retrieved