AI agents

Triaging a Failed Replay: Fold, Retrieval or Prompt

Antonio Evans9 min read

A clean three-panel diagnostic board on a neutral gray background.
Key points

Key points

  1. 1Read the three replay artifacts in a fixed order: the folded summary, the retrieved chunks, then the final answer.
  2. 2If the fact is absent from the folded summary, the loss happened upstream of generation and prompt edits cannot recover it.
  3. 3If the fact is in the chunks but missing from the answer, the generator ignored its context and the fix is grounding and instructions.
  4. 4Classify every red replay into fold, retrieval or prompt loss before changing any prompt, because each class has a different owner and fix.

Read the artifacts in order

A red replay run hands you three pieces of evidence, and they are not interchangeable. The folded summary is the compressed state the runtime carried forward after context pressure. The retrieved chunks are the passages that search put in front of the model. The answer is what the model produced. Reading them out of order is the most common triage mistake, because a plausible-sounding answer invites you to start editing the instructions, which is the last place you should look.

The reason order matters is direction of information flow. A fact can only reach the answer if it survives the fold (when the session is long) and survives retrieval (when the fact lives in an index rather than the conversation). Once it is missing from both upstream artifacts, no wording change can bring it back. Prompt work is a downstream intervention, so it can only fix downstream losses.

This is not a style preference. Agent harnesses that compact conversation history do so by summarizing or truncating, and the compression is lossy by design. One study of agent memory found that a production compaction prompt preserved only 53 percent of safety rules after a single round and 10 percent after five rounds (the compaction study). If your fact is one of the casualties, the answer was never available to the model.

A practical setup: make the replay harness emit all three artifacts with stable IDs and token counts. When a run goes red, open them side by side before you open the prompt editor. The rest of this article is the decision procedure for what you see.

What each artifact is telling you

Each artifact answers a different question, and confusing the questions is what produces wasted debugging time.

The folded summary answers: did the system carry the fact forward at all? It is the state after compaction, recursive summarization or eviction. If the runtime uses paging between a small in-context working area and external storage, the summary is the main context, the part the model can currently read (MemGPT on arXiv). If your fact is not there, check whether it was ever written to external storage. MemGPT-style systems move data between tiers through explicit store, retrieve, summarize and update operations, and a fact that was never stored cannot be retrieved later (hierarchical memory overview).

The retrieved chunks answer: did search surface the evidence? This is a pure information retrieval question, and it has standard metrics. Recall at k asks whether a known relevant document appears in the top k results, and precision at k asks how much of what you returned was relevant (Evidently AI RAG evaluation guide). For triage you mostly care about recall: is the chunk with the fact anywhere in the set that reached the model?

The answer answers: did the model use what it was given? Groundedness and faithfulness metrics exist precisely for this, and they compare claims in the output against the retrieved context rather than against the world (Confident AI RAG metrics).

A short checklist for reading an artifact:

ArtifactQuestion it answersWhat "present" looks likeWhat "absent" implicates
Folded summaryDid the fact survive compaction?The fact, or a paraphrase that preserves its conditionsFold policy, eviction threshold, summarizer prompt
Retrieved chunksDid search surface the evidence?A chunk containing the fact, ideally in the top ranksQuery construction, chunk boundaries, index coverage
Final answerDid the model use its context?The fact stated correctly with citationGrounding instructions, context ordering, task framing

Run this table against every red replay. The first row that fails is your class.

Fold loss: the fact never made it forward

Fold loss means the fact is missing from the folded summary. There are two sub-cases, and they have different fixes.

The first sub-case is that the summarizer never saw the fact. Maybe it was in a tool output that got cleared early, or in a turn that fell outside the window before the fact mattered. Harnesses differ here: some use a sliding window that keeps only the most recent turns, some use an LLM summarization pass, some clear large tool results while keeping the reasoning about them, and some layer these strategies (memory compaction in agent harnesses). A rolling window that drops older turns will lose any fact that was stated once early and needed later, and no amount of prompt engineering downstream will restore it.

The second sub-case is that the summarizer saw the fact and dropped or paraphrased it away. This is the compaction cliff in miniature. The failure is not random: it is uniform treatment of heterogeneous knowledge. A safety rule needs exact wording to stay enforceable, while a background observation tolerates heavy paraphrase. When both compete for the same token budget under a single summary policy, the rule loses just as easily as the trivia (the compaction study).

Fixes for fold loss:

  1. Add an explicit, writable working-context block for facts that must never be summarized, and have the runtime write to it on pressure warnings rather than on eviction. MemGPT pages this way: the queue manager alerts the model at a warning threshold so it can save important details before the flush threshold evicts anything (alphaXiv MemGPT overview).
  2. Classify lines by type before compaction and give each type its own retention policy. The compaction study calls this Knowledge Triage, and reports that typed compaction preserved two to four times more safety rules than the strongest single-shot LLM compactor at every ratio, with 96 percent recall over five rounds.
  3. Pin critical facts outside the summarizer's scope entirely, so a summary round cannot touch them.

The diagnostic signal that tells you which sub-case you are in: check the raw transcript for the fact. If it appears before the fold and not after, the summarizer dropped it. If it never appeared, the conversation never carried it and you have a missing-input bug rather than a fold bug.

Retrieval loss: search never found it

Retrieval loss means the fact is not in the summary and not in the retrieved chunks, but it does exist somewhere in your source material. This is the most common class in document-heavy systems, and it splits into three causes.

The first cause is query construction. The user's wording and the document's wording do not overlap, so the embedding search misses. Experienced debuggers fix this before touching anything else. In a study of engineers debugging RAG pipelines, the observed pattern was to enlarge chunks when the retrieved information looked insufficient, then to add a query rewriting step when the retrieved documents were right but the query was ambiguous (RAG Without the Lag). That two-step sequence, widen first, rewrite second, is a good default order.

The second cause is chunk boundaries. A sentence that says "the limit is 40, except in cases covered by section 12" is unusable if the chunk ends after "40." Chunking too large can bury a pertinent fact in noise, and chunking too fine can separate a fact from the qualifier that makes it actionable (Snorkel AI on RAG failure modes). Overlap helps, but structural chunking by section is usually better than fixed token windows.

The third cause is coverage and ranking. The fact may not be in the index at all, or it may be ranked below the top k cutoff. Top-k omission is a named failure mode in RAG evaluation: the definitive answer exists in the collection but does not rank highly enough to reach the context (Splunk on RAG failure modes). Coverage gaps produce the same symptom through a different door, and they are worth auditing separately because the fix is ingestion, not ranking.

A decision rule for retrieval loss: first check whether the source document exists in the index. If not, you have a coverage problem, and no retriever tuning helps. If it does, check whether the exact fact is in any chunk; if not, you have a chunking problem. If the chunk exists and still does not rank, raise k, add a reranker, or rewrite the query. Only then does embedding model choice come up.

Prompt loss: the fact was there and got ignored

Prompt loss means the fact is present in the retrieved chunks, correctly, and the answer is still wrong or silent. The model had what it needed and did not use it. This is the class prompt edits actually fix, and it is the one people habitually assume they have.

Three patterns recur. The first is synthesis drift: the model retrieves three chunks that are each correct, and combines them into a claim none of them supports. Inventory numbers, dates and entity names are the usual casualties (Towards AI on RAG in production). The second is silent substitution: the model fills the gap with prior knowledge because the instructions did not forbid it. The third is dilution: the fact is buried in the middle of a long context, and the model attends to the edges.

Fixes for prompt loss:

  • Require a quote-then-answer structure, so the model must reproduce the supporting sentence before it speaks.
  • State an explicit abstain rule: if the context does not contain the answer, say so. This is the behavior a faithfulness metric scores, and it is cheap to enforce in instructions.
  • Put the most relevant chunk first or last rather than in the middle, and deduplicate near-identical chunks so one fact does not crowd out another.
  • Add a citation requirement per claim, so an unsupported claim becomes visible in the output rather than buried in fluent prose.
SymptomMost likely classFirst fixWrong fix to avoid
Fact absent from summary and chunksRetrievalQuery rewrite or chunk boundariesRewriting system instructions
Fact absent from summary, present in transcriptFoldPinned working context, typed compactionLowering temperature
Fact in chunks, answer paraphrases it wrongPromptQuote-then-answer, abstain ruleRe-indexing documents
Fact in chunks, answer cites nothingPromptPer-claim citation requirementEnlarging top k
Fact in index, never retrievedRetrievalReranker or higher kAdding few-shot examples

A worked example with numbers

Suppose your replay suite has 200 cases, and 20 go red on a release candidate. You resist the urge to edit the prompt and run triage artifact by artifact.

You find the fact absent from the folded summary in 9 of the 20. Of those, 6 have the fact in the raw transcript, so the summarizer dropped it: fold loss. The other 3 never carried the fact at all, which points at an upstream tool call that did not run. You check the retrieved chunks for the remaining 11 and find the fact missing in 7. Of those 7, 2 have the source document absent from the index entirely (coverage), 3 have the fact split across two chunks by a boundary (chunking), and 2 have the right chunk ranked below the cutoff (ranking). That leaves 4 cases with the fact in context and a wrong answer: prompt loss.

So the distribution is 9 fold, 7 retrieval, 4 prompt. Had you started with prompt edits, you would have been working on 20 percent of the problem. The arithmetic generalizes: the upstream classes are usually the majority, which is why the prompt editor is the most expensive place to start.

There is a second payoff. Because retrieval and generation fail independently, evaluating them separately with their own metrics is what makes a failing score point at an owner rather than a mystery (component-level RAG evaluation). Fold, retrieval and prompt map cleanly onto memory engineering, search engineering and application engineering. Assign the ticket accordingly.

Instrument the replay so triage is cheap

Triage goes fast only if the artifacts are already in hand. Four instrumentation habits pay for themselves.

Log the artifact set with every run: summary text, chunk IDs with scores and ranks, and the answer with its citations. Send the same request to two configurations side by side when you can, because the contrast makes memory differences visible in a way single runs do not; this is how OpenAI's own memory demo compares trimming and compaction settings (memory strategies demo). Record token counts per artifact, since compaction that cuts input tokens heavily can be nearly free in quality: one evaluation of native compaction reported roughly 86 percent fewer input tokens with no measurable change to the aggregate score in a malware analysis harness (SentinelLABS). And keep a labeled set of queries with known answers, because without ground truth you cannot tell recall failure from relevance judgment.

One caution: keep the fold policy and the retrieval policy in separate configuration. When memory compaction and search tuning live in the same file, a change meant to fix fold loss quietly alters what gets retrieved, and your next triage is contaminated.

If you are running replays across several model families, one API key through Quanta Inference keeps the routing constant while you isolate the memory and retrieval variables.

FAQ

FAQ

What exactly is a folded summary in a replay run?

It is the compressed state the agent carried forward after context pressure, produced by summarizing, truncating or evicting earlier turns. It is what the model could read at the moment it answered, so it is the first thing to check when a fact goes missing. If the runtime pages between tiers, the folded summary is the in-context portion.

Why can't a prompt change fix a missing fact?

Instructions shape how the model uses what it has; they cannot supply content that was never in the context. If the fact is absent from both the summary and the retrieved chunks, the model has nothing to ground on, and the most a better prompt can do is make it abstain. That is a correctness win but not a fix for the missing fact.

How do I tell chunking failure from ranking failure?

Check whether the exact fact sits inside any single chunk in your index. If it is split across a boundary, it is chunking; fix the splitter or add overlap. If a complete chunk exists but never reaches the top k, it is ranking; raise k, add a reranker, or rewrite the query.

Is a longer context window a substitute for fold triage?

No. Larger windows reduce pressure but do not eliminate it, and models lose effective recall of early content well before the nominal window fills. Compaction also remains lossy per round, so facts still need a retention policy that treats important lines differently from background chatter.

How many replay cases do I need before trusting a classification?

Enough that the small classes are visible. A few dozen red cases is workable if they span your query types, since triage sorts them into fold, retrieval and prompt buckets and each bucket needs a handful of members to justify a fix. Below that, a single case may mislead you into rewriting a policy for one anomaly.

Sources

Sources

  1. The Compaction Cliff in Long-Running AI Agent Memory
  2. 2310.08560 MemGPT: Towards LLMs as Operating Systems - arXiv
  3. MemGPT: Hierarchical Memory Management - Emergent Mind
  4. A complete guide to RAG evaluation: metrics, testing and ...
  5. RAG evaluation metrics, answer relevancy, faithfulness ...
  6. Memory Compaction in AI Agent Harnesses: | by Plaban Nayak
  7. MemGPT: Towards LLMs as Operating Systems - alphaXiv
  8. RAG Without the Lag: Interactive Debugging for Retrieval ...
  9. Retrieval-augmented generation (RAG) failure modes and ...
  10. Mastering RAG: 8 Failure Modes to Evaluate Before Going ...
  11. When Retrieval Augmented Generation Fails in Production
  12. LLM Evaluation Metrics: The Ultimate LLM Evaluation Guide
  13. How AI Agent Memory Actually Works: Trimming, Compaction & ...
  14. Context Engineering | Compaction & Agent Memory for ...
About the author

About the author

Antonio Evans
Antonio Evans

Antonio Evans is the founder of Quanta Intelligence and a fractional CTO who builds HIPAA-ready AI systems for health and life-science companies. Before that he was technical co-founder of FriendsEAT for twenty years, CEO of Socialdraft, and a data engineer at IBM. Antonio lives with his dog Santino in Lisbon, Portugal.

All articles