Module 6 · Context management and reliability · Chapter 22
Keep critical facts alive in long conversations
- The context window is the whole memory. If a fact is not in what you send, Pine cannot use it.
- In a long chat, early and middle facts get weak attention, even when they still fit in the window.
- Fix it in your app: keep a short, structured case summary, update it each turn, and send it every turn.
The picture: a case file card pinned to the top of a messy desk. The desk can fill up. The card stays in sight.
Domain 5, Context Management and Reliability (15 percent of the exam). Manage context in long conversations. You should be able to:
- Explain why facts fade as a history grows, and why the middle fades most.
- Design a structured summary that carries critical facts forward, apart from the raw transcript.
- Decide which facts to pin and which can scroll away.
- Summarize and resume a long session without losing identity, money or policy facts.
Harbor & Pine Outfitters is a made-up company. Its support agent Pine, from chapter 3, handles a long chat about a damaged tent.
- Message 3: the customer verifies identity and gives order 73921.
- Message 41: Pine asks for identity proof and the order number again. The customer repeats both, then writes: "Forget it."
- Message 52, another day: Pine offers a $700 refund limit from an earlier, different case in the same long thread. This case limit is $500.
Nadia Okafor, head of support, counts 214 chats like this in a month. At a made-up $6 per repeat contact, rework alone costs about $1,284, before lost trust. Nothing was deleted. The facts were still in the history. They were just no longer in focus.
- Why the window forgets: attention fades in the middle.
- The fix: a pinned case summary, separate from the transcript.
- What to pin, and what can scroll away.
- Worked example: 60 messages, raw history versus summary plus recent.
- Lab: write Pine's case summary block and test your pin choices.
Step 1: The window is the whole memory
Why this step: most wrong exam answers trust the model to remember. It cannot.
Claude sees only the messages you send in this request. See Tokens and context windows for the basics. As the chat grows, three things happen:
- Early facts compete with many later messages for attention.
- Facts in the middle of a long history get the weakest attention. Teachers call this pattern lost in the middle.
- At the limit, old messages may be cut to make room, and then they are gone for real.
Think of a long meeting. You recall the first point and the last point well. Point 17 blurs.
Where the picture breaks down:
- A person can check their notes. The model has no notes except what you send.
- A person knows a number mattered. The model does not know which old number you will need later.
- Repeating a fact once does not fix this. Position and clutter still work against it.
Quick check: where did the fact go?
Next: the fix your app owns, not the model.
Step 2: Keep a case summary, separate from the transcript
Why this step: this is the design the exam rewards for Task statement 5.1.
Your app keeps one short block per case. After each turn, code or a checked update step rewrites it from tool results and confirmed decisions. Each new request sends:
- The system prompt and tools.
- The pinned case summary, near the start, in a fixed shape.
- The recent messages, not always the full raw transcript.
The summary is not a prose recap. Fixed fields force the facts that matter to stay present and easy to check. Tool results, not model guesses, should fill money and identity fields. That links to chapter 8 on sessions: when you resume a session, resume with this summary, not with 60 raw messages.
- Sixty messages hold everything, including greetings, dead ends and two different cases. The key facts sit buried in the middle.
- After each turn, your app updates fixed fields: verified identity, order, amounts, decisions and the policy limit for this case.
- The last few turns carry tone and the current question. Older talk survives only through the summary.
- Every request re-presents the pinned facts in the same place and shape, so Pine starts each turn with them in focus.
Next: which facts earn a pinned field.
Step 3: Pin what would hurt to lose, let the rest scroll
Why this step: pin everything and the summary becomes a second transcript. Pin too little and the bug returns.
| Pin it | Why | Let it scroll |
|---|---|---|
| Verified identity and customer ID | Re-asking breaks trust and flow | Greetings and small talk |
| Order number, item, amounts paid | Money decisions depend on exact numbers | Dead ends already ruled out |
| Decisions made and promised actions | Stops repeat questions and contradictions | Long explanations already given |
| Policy limit for this case ($500 auto refund) | Stops limits leaking in from other cases | General chat about the weather |
Rule of thumb: if losing the fact changes money, identity, safety or a promise, pin it. If it only changes tone, let it scroll.
Quick check: which fact gets pinned?
Do this: pick your answer, then press the button.
Duplication pays twice for the same clutter. The middle facts are still in the middle, twice. A short summary near the start is cheaper and puts the facts in focus.
Next: the same 60-message case, costed two ways.
Step 4: Worked example, raw history versus summary plus recent
Why this step: the summary wins on focus first and cost second. The numbers show both.
All numbers below are made-up. Made-up price: $3 per million input tokens, $15 per million output tokens. One support case, 60 messages:
Raw history, turn 60:
1. Full transcript: 60 messages at about 300 tokens each = 18,000 tokens. Plus system and tools, 1,500. Input per call: about 19,500 tokens.
2. The order number sits at message 3, deep in the middle of what follows. It is present, and weak.
Summary plus recent, turn 60:
3. Case summary: about 250 tokens. Recent 8 messages: 8 times 300 = 2,400 tokens. Plus system and tools, 1,500. Input per call: about 4,150 tokens.
4. Saving per call: 19,500 minus 4,150 = 15,350 tokens, about 79 percent less input.
5. Cost per call at the made-up price: raw 19,500 / 1,000,000 times $3 = $0.0585. Summary 4,150 / 1,000,000 times $3 = $0.0125.
6. Over 1,000 long chats a month, that gap is about $46 saved, and the real win: identity, order and limit arrive pinned on every call.
When the chat grows past a set size, summarize and carry forward: fold older turns into the summary, keep recent turns raw, and store the full transcript outside the prompt for audit. On resume, load the summary first.
Next: build the summary block for Pine.
Step 5: Hands-on lab, write Pine's case summary
Why this exercise: on the exam you judge summary designs. In production you write the fields and the update rules.
Part A: the block (illustrative)
CASE SUMMARY (pinned, update after every turn)
customer_id: C-1042
identity_verified: yes, message 3, by get_customer
order_id: 73921
item: 3-person tent, paid $429.00
issue: pole snapped on first use
decisions: replacement pole offered, customer chose refund
amounts: refund agreed $429.00
policy_limit_this_case: auto refund up to $500, above needs human
open_items: refund not yet issued
do_not_ask_again: identity, order number
Update rules (illustrative):
1. Fill identity, order and amounts from tool results only.
2. Add a decision only after the customer confirms it.
3. One case per summary. A new case starts a new summary.
4. Never copy a limit or amount from another case.
- Copy the block. Add one field Pine needs for escalations.
- Write the update rule for that field: what source fills it, and when.
- Check rule 3 against the cold open. Which failure does it kill?
Part B: pin it or let it scroll
Sort each fact. If you miss, read the hint.
Lab: Step 3 gives the rule of thumb: if losing a fact would change money, identity, safety or a promise, pin it in the case summary, where it is re-sent in a fixed place every turn. This lab runs in your browser and needs JavaScript enabled.
- Pinned facts share a trait: losing one changes money, identity or a promise.
- The summary stays short because most of a chat is tone, not facts.
- Never trust the model to remember a number it saw 40 messages ago. If a number matters, your app carries it.
Next: what this looks like in real teams, then the traps.
Long-running support and coding tools commonly carry a compact state block forward instead of replaying everything, because replay cost grows with every turn and old details get harder to use. Treat exact product behaviour as version-dependent: check the current docs. Harbor & Pine is a made-up company, and its numbers here are made up too.
Mix-ups to avoid
- Fits the window, so it is remembered. No. Presence is not focus. Pin and re-present key facts.
- A prose recap is a summary. A free-text recap can drop or alter a number. Use fixed fields filled from tool results.
- Summarize once, at the end. Too late. Update the summary each turn, and summarize and carry forward as the chat grows.
- One summary for the whole thread. Threads hold many cases. Mixing them leaks limits and amounts across cases.
- Ask the model to recall the total. For money, read the pinned field or call the tool again. Recall is a guess.
Chapter quiz
Five questions. Score 70% or more to mark this chapter complete.
Review this chapter in 5 minutes
Watch the whole chapter recapped: lost in the middle, the pinned structured case summary, what to pin versus let scroll, and summarize and carry forward.
- The context window is the whole memory. What is not sent does not exist.
- Long histories dilute attention. Middle facts fade most, even when everything fits.
- The fix is app-owned: a short structured case summary, updated each turn, sent each turn, separate from the raw transcript.
- Pin identity, order, amounts, decisions and this case's policy limit. Let greetings and dead ends scroll.
- Made-up worked example: turn 60 costs about 19,500 input tokens raw versus about 4,150 with summary plus recent, about 79 percent less.
- Summarize and carry forward as the chat grows. Resume with the summary, as in chapter 8.
- One summary per case. Never copy a limit or amount from another case.
Decision rule: if losing a fact would change money, identity or a promise, your app pins it in the summary and re-sends it. Never leave it to model recall.
Independent exam preparation. Not affiliated with or endorsed by Anthropic.
Review
Glossary
- Context window
- All the text sent in one request. It is the model's whole memory for that reply. Example: Pine's summary plus recent messages.
- Lost in the middle
- The pattern where facts in the middle of a long history get the weakest attention. Example: an order number from message 3 of 60.
- Case summary
- A short structured block your app keeps per case and re-sends each turn. Example: identity, order, amounts, decisions, limit.
- Pinned fact
- A fact kept in the summary because losing it changes money, identity or a promise. Example: verified identity.
- Raw transcript
- The full message history, word for word. Example: all 60 messages, greetings included.
- Summarize and carry forward
- Folding older turns into the summary and keeping only recent turns raw. Example: at 60 messages, keep the last 8 raw.
- Resume
- Restarting a paused session from stored state. Example: loading the case summary before the next reply.
- Cross-case leak
- A fact from one case being applied to another. Example: a $700 limit used on a $500 case.
Next: "Escalation, ambiguity and error propagation: when to hand off, and how errors travel".