Skip to main content
AI Agents & Automation

⏱ About 20 min20 XP

Memory Failures

Agent memory systems fail. Not occasionally — regularly, in specific patterns that engineers who build agents encounter again and again. Understanding these failure modes at the root-cause level is the difference between debugging an agent effectively and spending days chasing symptoms. Each failure has a distinct shape, a distinct cause, and a targeted fix. This lesson catalogs the most important ones.

Failure Mode 1: Context Loss

Context loss occurs when information the model needed was never placed in its prompt, or was evicted before it was needed. The agent appears to 'forget' something that happened earlier. The model is not at fault — it never received the information. Context loss is the most common agent memory failure and has multiple sub-causes. A rolling window that evicted the original goal statement. A tool result that was captured but not injected into the next prompt. A decision from step 3 that was not included in the state block at step 10. A developer who forgot to add a particular field to the context assembly logic. The diagnostic signature of context loss is behavioral inconsistency: the agent acts as if an earlier event did not happen. The fix is always the same in structure: trace backward from the inconsistent behavior to the specific piece of information that was missing, find where it should have been included in context assembly, and add it.

The Model Is Blameless

When an agent exhibits context loss, the temptation is to blame the model for 'forgetting.' But the model never had the information. The failure is in the code that assembles the prompt. Effective debugging means asking: what was not in the context? — not: why did the model forget?

Failure Mode 2: Stale Memory

Stale memory is the opposite problem: information that is in the context, but is outdated. The agent is acting on facts that were true at some earlier point but have since changed. A RAG system that retrieved a product's price two days ago and never re-fetched it. A state object that recorded a file's contents at step 1 but the file was modified by a tool at step 7. A summary from early in the session that reflects the user's original plan, but the plan changed and the summary was never updated. Stale memory is particularly dangerous because the model behaves confidently — it has information, it just is not the right information anymore. Context loss produces inconsistency; stale memory produces confident wrongness, which is harder to detect and more likely to cause real harm if the agent takes external actions.

Failure Mode 3: Retrieval Misfire

Retrieval misfire occurs in RAG and similar systems when the retrieval step returns the wrong documents. The model is grounded in content — it is not hallucinating from thin air — but it is grounded in the wrong content. The retrieved chunks are plausible but not actually relevant, or they are relevant to a superficially similar query but not the actual question. Retrieval misfires have several root causes. The query embedding may not capture the user's actual intent if the question is ambiguous. The corpus may lack the right documents, forcing the nearest-neighbor search to return the least-wrong thing instead of the right thing. Chunk size may be too large, causing a retrieved chunk to contain the relevant sentence buried in irrelevant text. Or the top-k parameter may be too small, excluding the relevant document from consideration. The diagnostic signature of retrieval misfire is a response that sounds authoritative but is about the wrong thing — the model answered a different question than was asked, using real retrieved text.

Failure Mode 4: Hallucinated Recall

Hallucinated recall is when the model describes remembering something that was never in its context at all. It fabricates a prior conversation, invents a tool result, or confidently states what a past step produced — none of which actually happened. This is the inverse of context loss: instead of the model being silent about missing information, it fills the gap with invented content. Hallucinated recall is rarer than context loss in well-designed systems, but it is the most dangerous failure mode because it is the hardest to detect from outside the agent. A human reviewing the agent's output sees confident, internally consistent claims that may look entirely plausible — but they are fabricated. The mitigation is grounding: never ask the model to recall; always inject the actual record. If you need the model to know what happened in step 3, include step 3's output in the prompt. Do not ask 'what did you find in step 3?' — the model will answer whether or not it actually remembers.

Match each symptom to the memory failure mode that most likely caused it.

Terms

Agent recommends a product at $29.99 when it was repriced to $49.99 yesterday
Agent confidently describes completing a subtask that never actually ran
Agent proposes reusing a failed approach it already tried earlier in the task
A RAG system answers a revenue question using a customer-retention document
Agent contradicts a constraint from the first message after a rolling window dropped it

Definitions

Hallucinated recall — the agent invents a memory of something that never happened
Stale memory — stored information is now out of date
Context eviction — an old but still-relevant message was removed to save space
Context loss within a task — earlier steps fell out of the working context
Retrieval misfire — the wrong document was fetched for the query

Drag terms onto their definitions, or click a term then click a definition to match.

Ground Everything

The single most effective mitigation for hallucinated recall is never asking the model to remember — instead, inject the actual record. Replace 'What did you find in step 3?' with a prompt that includes step 3's actual output. The model cannot fabricate what is already printed in front of it.

Diagnosing Memory Failures Systematically

When an agent behaves incorrectly, the memory failure diagnosis process follows a consistent sequence. First, identify the incorrect behavior precisely — not 'the agent is confused' but 'the agent recommended action X in step 8, when action X was explicitly ruled out in step 2.' Second, reconstruct the exact prompt that was sent for the failing step. This requires logging — agents that do not log their full prompts are nearly impossible to debug. Third, check whether the relevant information was present in that prompt. If it was absent: context loss. If it was present but outdated: stale memory. If it was present but from the wrong source: retrieval misfire. If the model invented something not present at all: hallucinated recall. Fourth, trace back to the cause: what step failed to write the information, retrieve it, or include it in context assembly? Fix that step.

An agent claims: 'In step 4, I retrieved three papers on climate adaptation in coastal cities.' Examination of the logs shows step 4 actually ran a web search that returned zero results. What failure mode is this?

Which mitigation is most directly targeted at preventing hallucinated recall?

Memory Failure Forensics

  1. Each scenario below describes a failing agent. For each one: (a) identify the failure mode (context loss, stale memory, retrieval misfire, or hallucinated recall), (b) explain the root cause in one sentence, and (c) describe the specific fix.
  2. Scenario 1: An agent helping with trip planning was told in message 1 that the budget is $2,000. At step 15, the agent recommends a hotel that costs $3,500 per night. The rolling window is set to 20 messages, and the conversation is now 18 messages long.
  3. Scenario 2: A customer service agent RAG system answers a question about the company's refund policy using a chunk from a three-year-old version of the policy document that was never removed from the vector store.
  4. Scenario 3: A research agent is asked to list what it found in steps 1-3. It produces a detailed list of sources. When the engineer checks the step logs, steps 2 and 3 both returned errors and produced no output — the model invented the sources.
  5. Scenario 4: An agent that processes invoices is currently working on invoice #47. It applies a discount rate of 12%, which was the correct rate two API calls ago but has since been updated to 8% by an external pricing system. The agent's state object was populated at startup and never refreshed.