Agent Memory Errors Handbook: Cases 16–20
This installment is part of the Agent Memory Errors: 100 Cases Handbook series.
Case 16: Long-term Memory Management Errors — Memory Consolidation Sleep Cycle Disruption
Scenario
The Agent mimics human sleep by running memory consolidation from 2 AM to 4 AM, transferring important short-term memories to long-term memory. During a maintenance window, the Agent instance restarts and consolidation is skipped. All conversation memories from that day remain in short-term memory.
Error Manifestation
The next day the user continues yesterday’s discussion (“About that plan, I have one more point”). The Agent cannot recall yesterday’s content at all, making the user feel forgotten.
Solution
- Put consolidation tasks on a persistent queue (e.g., Redis Stream) so unfinished tasks resume after restart
- Use write-ahead logging: all short-term changes are logged first, and consolidation can replay from the log
- Make consolidation idempotent so the same memory processed multiple times does not create duplicates
Principle
Memory consolidation is essential for forming long-term memory. If it is unreliable, short-term memory becomes de facto volatile storage, and the Agent suffers severe overnight forgetting.
Case 17: Long-term Memory Management Errors — Autobiographical Memory Narrative Distortion
Scenario
An Agent with autobiographical memory records its own experiences, such as “I successfully helped user A solve problem X.” Over time, successful episodes are recorded and reinforced more often, while failures are ignored or diluted. When asked “What are you good at?” the Agent builds an overconfident self-image.
Error Manifestation
The Agent claims “I have 95% accuracy in legal questions” when the real figure is 72%. This overconfidence leads users to over-rely on the Agent in high-risk situations.
Solution
- Record autobiographical memories in both directions: successes and failures, with a minimum quota for failures
- Periodically audit and calibrate autobiographical memories against external logs
- Require the Agent to cite verifiable data, not subjective memory, when generating self-descriptions
Principle
Human autobiographical memory also shows self-serving bias. Without deliberate balancing, Agents naturally accumulate positive narratives and form a memory echo chamber.
Case 18: Long-term Memory Management Errors — Working Memory Gatekeeping Failure
Scenario
The Agent’s working memory should retain only information most relevant to the current task. In a multi-turn conversation the user first asks, “Recommend an Italian restaurant,” then shifts to “Help me write a resignation letter.” The gatekeeping mechanism fails, and the restaurant recommendation stays in working memory.
Error Manifestation
While drafting the resignation letter, the Agent inserts irrelevant text such as “As I experienced at that Roman restaurant, life requires making choices,” appearing highly unprofessional.
Solution
- Explicitly refresh working memory when a topic shift is detected via intent classification or topic-drift detection
- Assign relevance scores to working-memory items and evict those below threshold
- Use attention masking to suppress working-memory entries irrelevant to the current query
Principle
Working memory capacity is limited (Miller’s Law: 7±2 chunks). The gatekeeping mechanism determines what enters consciousness; Agents need to simulate it to avoid cognitive overload and interference.
Case 19: Long-term Memory Management Errors — Long Term Memory Retrieval Threshold Drifting
Scenario
The Agent uses a fixed cosine-similarity threshold of 0.75 for long-term memory retrieval. Over time the embedding model is upgraded from v1 to v2, so early memories and new queries live in different semantic spaces. Even highly relevant content scores well below 0.75.
Error Manifestation
The user asks a question closely related to an early conversation, but the Agent cannot retrieve that early memory, appearing unfamiliar with long-time users. Newer memories still retrieve normally.
Solution
- Re-encode all historical memories (re-index) when upgrading embedding models
- Tag each memory with the embedding-model version used at write time and bucket retrieval by version
- Use normalization, such as a learned linear transformation, to align old and new embedding spaces
Principle
Embedding-model upgrades shift the semantic space. The same text can have very different vectors across versions. Without re-indexing or alignment, historical memories become dormant in the database.
Case 20: Long-term Memory Management Errors — Memory Dependency Graph Cyclic Reference
Scenario
The Agent links memories by dependency (e.g., “Memory B is based on Memory A”). User A says, “My boss is B,” and user B says, “My subordinate is A.” The system creates mutual dependencies. When the Agent retrieves “A’s organizational relationship,” the dependency parser loops infinitely between the two memories.
Error Manifestation
The retrieval request times out, the Agent cannot answer organizational-structure questions, and CPU usage spikes.
Solution
- Detect cycles when building the dependency graph, using topological sorting or DFS visited-node markers
- Cap dependency resolution depth (e.g., at most five layers)
- On detecting a cycle, merge the related memories into a consistent view and flag the contradiction
Principle
Allowing cycles in a memory dependency graph causes infinite recursion during resolution. This is analogous to circular foreign keys or infinite loops and requires cycle detection.
Source: Agent Search