Lesson 2 of 3 Optimizing Duration, Context and Tokens

Diagnosing Context Window Failures

This lesson explains the symptoms, causes and fixes of the four context window failures the skills outline names, sliding-window amnesia, summary drift, vector-only recall and entity continuity issues, so they can be recognized in scenarios.

Learning outcomes

After completing this lesson, you will be able to:

  • Distinguish sliding-window amnesia from summary drift.
  • Explain why vector-only recall misses exact identifiers.
  • Prevent entity continuity issues with stable entity IDs.

Sliding-window amnesia and summary drift

Sliding-window amnesia appears when an agent keeps only the most recent N messages or tokens. Facts stated early, such as an account number, a constraint ("no flights before 9 a.m.") or a decision, silently fall out of the window, and the agent asks again or violates the constraint. The fix is to pin key facts in structured state or memory that is always injected, and to summarize rather than drop older turns.

Summary drift appears when context is compacted by summarizing, and later the summary itself is summarized again. Each pass loses or subtly alters details: amounts are rounded, conditions disappear, a tentative idea becomes a decision. The fix is to summarize from the original turns (kept in storage), preserve critical fields verbatim in structured state, and test summaries against their sources.

Sort into groups

Amnesia or drift?

Exam skills 3.2.2

Diagnose each symptom as sliding-window amnesia or summary drift.

Log in to try this activity Interactive activities are free with an account.

Vector-only recall

Vector-only recall appears when memory or retrieval depends only on embedding similarity. Embeddings capture meaning, so they miss exact identifiers (order numbers, codes), numbers, negations and recency: the agent cannot find "invoice INV-2026-0418" or retrieves an older, similar memory instead of the latest one. Fixes are hybrid retrieval with keyword search, structured lookups by ID for entities, metadata such as timestamps with recency weighting, and filters.

True or false

Vector-only recall

Exam skills 3.2.2

Check why similarity-only retrieval fails and how to fix it.

Log in to try this activity Interactive activities are free with an account.

Entity continuity issues

Entity continuity issues appear when the agent loses track of which entity a reference means: "the second order", "her account", "that supplier". They are common after hand-offs between agents, after compaction and in conversations involving several similar entities. The fix is an explicit entity registry in shared state, with stable IDs, display names and the current focus, passed to every agent and updated when the user's focus changes.

The following table summarizes the four failures.

FailureSymptomCauseFix
Sliding-window amnesiaEarly facts forgottenOnly last N turns keptPinned state, memory, summaries
Summary driftDetails change over timeSummaries of summariesSummarize from source; keep fields verbatim
Vector-only recallExact IDs or latest facts missedSimilarity-only retrievalHybrid, ID lookups, recency
Entity continuityWrong person, order or accountReferences lost across turns or agentsEntity registry with stable IDs
Match the pairs

Symptoms to fixes

Exam skills 3.2.2

Match each context failure with its fix.

Log in to try this activity Interactive activities are free with an account.
Worked example

The wrong patient

A clinical scheduling assistant hands off between an intake agent and a scheduling agent. When a parent books appointments for two children in one conversation, the scheduling agent sometimes books the second appointment for the first child.

This is an entity continuity issue. An entity registry in the shared state, listing both children with stable patient IDs and marking which one the current request concerns, lets the scheduling agent resolve "her" and "the second appointment" correctly; the booking tool should also confirm the patient name before committing. A larger context window would not resolve the ambiguity.

Check yourself

What is the difference between sliding-window amnesia and summary drift?

Show answer

Amnesia is when early facts fall out of the context window. Drift is when details change through repeated summaries.

Exam Tips

Remember for the exam

  • Amnesia: early facts fall out of a window. Drift: details change through repeated summaries.
  • Vector-only recall misses exact IDs and recency; add keyword and structured lookups.
  • Entity continuity needs a registry with stable IDs shared across agents.