5.1 Manage conversation context to preserve critical information across long interactions
Preserve critical facts across long interactions by keeping transactional data in a persistent structured layer, trimming tool results before they accumulate, and structuring aggregated inputs so nothing important is lost in summaries or in the middle of long inputs.
Key points
- 1
Progressive summarisation is lossy in a predictable direction: numbers, percentages, dates, order numbers and customer-stated expectations ("refund of $84.50 by Friday") become vague phrases ("a refund soon"). Every additional round of summarising compounds the loss.
- 2
Fix it structurally: extract transactional facts (amounts, dates, order numbers, statuses, stated expectations) into a persistent "case facts" block that is included in every prompt and sits outside the summarised history. Instructions such as "be thorough when summarising" are prompt pleading, not a control.
- 3
For multi-issue sessions, keep a structured issue ledger (one record per issue: order id, invoice id, amount, status) as a separate context layer that is updated as facts arrive, so amounts never get attached to the wrong order.
- 4
The case-facts block complements the conversation history; it does not replace it. The Messages API is stateless, so conversational coherence (what was already asked, answered and promised) depends on passing the complete or compacted history in each request. Prompt caching lowers the cost of resending a prefix but stores no state.
- 5
Tool results accumulate in context and consume tokens disproportionately to their relevance, for example 40+ fields per order lookup when five matter for a return. Trim to the relevant fields before the result enters context, in the tool handler or a
PostToolUsehook; telling the model to "ignore" fields does not remove the tokens. - 6
Lost-in-the-middle: models reliably process the beginning and end of long inputs and may omit findings from the middle. Put a key-findings summary first and organise detailed results under explicit section headers. Instructions to "pay equal attention" do not change where information sits.
- 7
When downstream agents have limited context budgets, modify upstream agents to return structured data (key facts, citations, relevance scores, dates, source locations, methodological context) instead of narrative and reasoning chains. Truncation and rolling summaries discard information unpredictably.
- 8
Require subagents to include metadata (dates, source locations, methodological context) in structured outputs so synthesis can interpret findings correctly later.
- 9
Larger context windows delay context problems and do not improve recall quality over long inputs; "switch to a bigger model" is the classic non-answer distractor.
- 10
In Claude Code, compaction keeps architectural decisions, unresolved issues and implementation details while discarding redundant tool output; the art is choosing what to keep.
/compact <instructions>lets you say what to preserve.
Read the source
Test yourself on 5.1 Manage conversation context to preserve critical information across long interactions
Ten questions, with the answer and explanation after each one.