中文

Agent Memory Errors Handbook: Cases 26–30

Short-term Memory, Context, Agent Memory

Agent Memory Errors Handbook: Cases 26–30

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

Case 26: Short-term Memory / Context Errors — In Context Learning Example Contamination

Scenario

The Agent uses few-shot prompting with three fixed examples in the system prompt. In one conversation the user’s input happens to resemble a format from an example (e.g., a JSON schema). The LLM confuses the user input with the examples and treats it as part of a fourth example.

Error Manifestation

The Agent’s output format is contaminated by the “fourth example” and starts mimicking the non-standard format in the user input instead of following the defined output spec.

Solution

  1. Use explicit example separators such as === Example 1 ====== End Example ===
  2. Isolate examples from user input with special tokens such as <|endofprompt|>
  3. Use dynamic example selection: pick the most relevant examples from a library rather than using fixed examples

Principle

The strength of in-context learning is also its weakness: LLMs cannot strictly distinguish template examples from user data. Format contamination is a known risk of few-shot prompting.


Case 27: Short-term Memory / Context Errors — Conversation Branch Merged Without Resolution

Scenario

The user and Agent discuss whether remote work should be universal. The user first gives arguments supporting remote work (Branch A), then arguments against it (Branch B), and finally asks, “What do you think?” The Agent’s context contains both branches but does not mark them as opposing assumptions.

Error Manifestation

The Agent replies with both “Remote work indeed improves efficiency” and “But face-to-face collaboration is irreplaceable” without clarifying that these are two different perspectives. The user finds the stance vague.

Solution

  1. Use a conversation tree rather than linear context, tagging each point with its branch and assumption
  2. When merging branches, explicitly label “Under assumption X” and “Under assumption Y,” or ask which branch to discuss
  3. Use belief-state tracking: maintain support/oppose/pending labels for each proposition

Principle

Real conversations are non-linear and include hypotheticals and role-play. Linear context cannot represent branching structure, and merging branches creates logical conflicts. Conversation trees are a more precise model.


Case 28: Short-term Memory / Context Errors — Summarization Induced Fact Substitution

Scenario

After a long conversation, the Agent compresses the context. The user originally said, “I like PyTorch, but company projects require TensorFlow.” For brevity, the summary becomes “User develops with TensorFlow.”

Error Manifestation

Later, the Agent recommends TensorFlow tools and resources based on the summary, ignoring the user’s actual preference for PyTorch. The user feels the Agent was not really listening.

Solution

  1. Apply a fact-fidelity constraint: instruct the summarizer to compress wording without changing facts
  2. Use extractive summarization instead of abstractive summarization so key sentences remain verbatim
  3. Back-translate the summary into a longer text and check factual consistency with the original

Principle

Abstractive summarization may perform semantic approximation during compression. Even when the gist is preserved, small changes in specific facts—preferences, numbers, names—can bias later reasoning.


Case 29: Short-term Memory / Context Errors — Context Window Fragmentation Tool Calls

Scenario

The Agent uses a tool chain for complex tasks. Each tool call includes the tool definition (JSON Schema), parameters, and results. In one data-analysis task the Agent calls ten tools; each call’s schema and result consume 500 tokens, totaling 5,000 tokens. With the system prompt included, less than 1,000 tokens remain for the user’s conversation.

Error Manifestation

The user’s next input is truncated. The Agent sees only the first half of the question, misunderstands the intent, and gives a wrong analysis.

Solution

  1. Compress tool-call history: keep only tool name, key parameters, and result summary; drop full schemas and redundant output
  2. Use a tool-memory cache: store frequently used results externally and keep only reference IDs in context
  3. Allocate an independent context budget for tool calls (e.g., at most 30%) and compress the oldest tool records first when exceeded

Principle

Tool calls consume large amounts of context. Without management, tool history crowds out user content, producing the experience of the user being cut off mid-sentence.


Case 30: Short-term Memory / Context Errors — Temporal Marker Ambiguity Resolution

Scenario

On Monday the user says, “Yesterday I went to the doctor.” The Agent records “User went to the doctor yesterday.” On Wednesday the user asks, “When was my last doctor visit?” The Agent computes “yesterday” from the current context as Tuesday, but the user’s “yesterday” meant Sunday.

Error Manifestation

The Agent answers, “You went to the doctor on Tuesday.” The user corrects, “I went on Sunday.” The Agent appears confused about time.

Solution

  1. Normalize times when recording: convert relative expressions (yesterday, next Wednesday) to absolute timestamps
  2. Store both the original expression and the normalized timestamp; choose the appropriate expression when answering
  3. Set validity periods for time-sensitive records, e.g., automatically archive “meeting tomorrow” after the meeting passes

Principle

Natural-language time expressions are relative to speech time. Agents must anchor them to absolute time; otherwise temporal references drift as the session progresses.

Source: Agent Search

引用格式

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

Share to

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

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