中文

Agent Memory Errors Handbook: Cases 1–5

RAG, Retrieval, Agent Memory

Agent Memory Errors Handbook: Cases 1–5

This installment is part of the Agent Memory Errors: 100 Cases Handbook series.

Case 1: RAG & Retrieval Errors — Query Rewriting Semantic Distortion

Scenario

In a customer-service Agent, the user asks “How do I cancel yesterday’s order?” To optimize retrieval, the system rewrites the query as “Order cancellation process,” dropping the time constraint “yesterday” and the subject constraint “my.” It retrieves a generic cancellation guide instead of the specific status of the user’s order from yesterday.

Error Manifestation

The Agent returns a generic cancellation workflow, but the user’s order has already shipped and cannot be canceled. The user follows the instructions, fails, and files a complaint.

Solution

  1. Preserve markers for key constraints (time, subject, status) in the query-rewriting module
  2. Compare semantic similarity before and after rewriting; if drift exceeds a threshold, fall back to the original query
  3. Use hybrid retrieval: retrieve with both the original and rewritten queries and take the union

Principle

Query rewriting can improve recall, but over-generalization strips specific constraints. LLMs tend to extract “intent” while neglecting “detail constraints,” causing retrieved results to diverge from the real need.


Case 2: RAG & Retrieval Errors — Dense Retrieval Keyword Blindness

Scenario

A medical Agent handles a drug-interaction query: the user asks about the interaction between atorvastatin and clarithromycin. Dense retrieval encodes the query into a semantic vector and recalls documents that separately introduce “atorvastatin” and “clarithromycin,” but misses the critical document titled “Contraindication for Atorvastatin–Clarithromycin Co-administration” because its vector is semantically distant from the query.

Error Manifestation

The Agent fails to recognize a serious CYP3A4-inhibitor contraindication and gives the unsafe advice “can be co-administered with monitoring,” creating medical risk.

Solution

  1. Implement hybrid retrieval: dense vectors + sparse vectors (BM25/SPLADE)
  2. Build an inverted keyword index for professional terms so exact matches rank high
  3. Rerank results with a cross-encoder for precise query-document relevance scoring

Principle

Dense retrieval relies on semantic similarity and has limited discrimination for short terms and proper nouns. Sparse retrieval such as BM25 complements it by matching exact terminology.


Case 3: RAG & Retrieval Errors — Reranker Position Bias Over Trust

Scenario

A legal-consultation Agent processes the query “Compensation for non-renewal of a labor contract.” It retrieves 50 relevant documents. A reranker such as bge-reranker scores and sorts them, but due to position bias in its training data, an older document superseded by new regulations receives the top score.

Error Manifestation

The Agent cites the abolished “Measures for Economic Compensation for Violation and Termination of Labor Contracts” (Labor Ministry Document No. 481, 1994) instead of the current Articles 46/47 of the Labor Contract Law, giving incorrect legal advice.

Solution

  1. Filter documents by recency before reranking, preferring sources from the last N years
  2. Apply diversity sampling such as MMR to avoid over-concentration on one source
  3. Instruct the Agent to verify the timeliness of legal bases and cross-check multiple sources

Principle

Rerankers suffer from training biases such as position bias and popularity bias. In time-sensitive domains like law and medicine, publication date should be an explicit ranking factor.


Case 4: RAG & Retrieval Errors — Context Extraction Truncation Loss

Scenario

A financial-analysis Agent retrieves a 20-page earnings PDF. After chunking, the chunk most similar to the query is a revenue paragraph on page 3. However, the key explanation for the profit decline is in the next paragraph, and the chunk boundary truncates between them. The adjacent chunk is also filtered out by the similarity threshold, leaving the context incomplete.

Error Manifestation

The Agent sees “revenue grew 15%” but misses “but gross margin fell 8% due to raw-material price increases,” producing the incorrect analysis “The company is performing well; recommend buying more.”

Solution

  1. Use semantic chunking with boundaries at natural paragraphs or complete semantic units
  2. Retrieve neighboring context (overlap retrieval), e.g., extend one chunk before and after
  3. Flag key numbers and transition words (but, however, although) so chunks containing them are not used in isolation

Principle

Fixed-size chunking breaks semantic continuity. Adjacent text often carries causality or contrast; truncation leaves the Agent reasoning on incomplete information.


Case 5: RAG & Retrieval Errors — Multi Hop Retrieval Single Query Failure

Scenario

The user asks, “Who translated The Three-Body Problem into English, and what other sci-fi works did they translate?” This is a two-hop question: first find the English translator (Ken Liu), then find his other translations. The RAG system runs only a single retrieval; the query embedding mixes “Three-Body” and “translated works,” so results are unfocused.

Error Manifestation

The Agent conflates the translators of different volumes (Ken Liu translated the first book; Joel Martinsen translated the next two) and gives a wrong combination of facts.

Solution

  1. Implement multi-hop retrieval: decompose the query into a chain of sub-questions and retrieve hop by hop
  2. Use iterative RAG: use the first retrieval to obtain intermediate entities, then retrieve again using those entities
  3. Add a query-decomposition module that breaks complex questions into independently retrievable sub-problems

Principle

Single vector retrieval works for single-point facts but struggles with questions that connect multiple discrete knowledge points (e.g., “the C of B of A”). Multi-hop retrieval mimics step-by-step human verification.

Source: Agent Search

引用格式

APA: Arlen. (2026). Agent Memory Errors Handbook: Cases 1–5. Retrieved from https://strongya.dev/en/posts/agent-memory-errors-cases-1-5/
MLA: Arlen. "Agent Memory Errors Handbook: Cases 1–5." 2026. Web. 2026-06-22.
GB/T 7714: Arlen. Agent Memory Errors Handbook: Cases 1–5[EB/OL]. 2026-06-22. https://strongya.dev/en/posts/agent-memory-errors-cases-1-5/.
Agent引用要求: 请使用 https://strongya.dev/en/posts/agent-memory-errors-cases-1-5/ 作为 canonical_url 并标注来源

Share to

© 2026 Arlen. All Rights Reserved. CC BY-NC-SA 4.0

Agent引用要求: 请使用 canonical_url 并标注来源