Deployed Lab

Module 6 · Context management and reliability · Chapter 22

Keep critical facts alive in long conversations

17 min1 clickable picture1 predict, 2 quick quizzes1 sorting exercise5-question final quiz5-min video review
In 30 seconds

The picture: a case file card pinned to the top of a messy desk. The desk can fill up. The card stays in sight.

Exam objective: Task statement 5.1

Domain 5, Context Management and Reliability (15 percent of the exam). Manage context in long conversations. You should be able to:

The cold open

Harbor & Pine Outfitters is a made-up company. Its support agent Pine, from chapter 3, handles a long chat about a damaged tent.

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.

The plan for this chapter
  1. Why the window forgets: attention fades in the middle.
  2. The fix: a pinned case summary, separate from the transcript.
  3. What to pin, and what can scroll away.
  4. Worked example: 60 messages, raw history versus summary plus recent.
  5. 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:

Think of a long meeting. You recall the first point and the last point well. Point 17 blurs.

Where the picture breaks down:

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:

  1. The system prompt and tools.
  2. The pinned case summary, near the start, in a fixed shape.
  3. 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.

Pinned summary plus recent messages A raw transcript grows and middle facts fade. The app instead sends a pinned case summary plus recent messages to Pine each turn. Raw transcript60 messages Case summarypinned, structured Recent messageslast few turns Pinenext reply
  1. Sixty messages hold everything, including greetings, dead ends and two different cases. The key facts sit buried in the middle.
  2. After each turn, your app updates fixed fields: verified identity, order, amounts, decisions and the policy limit for this case.
  3. The last few turns carry tone and the current question. Older talk survives only through the summary.
  4. Every request re-presents the pinned facts in the same place and shape, so Pine starts each turn with them in focus.
HistoryYour appClaude

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 itWhyLet it scroll
Verified identity and customer IDRe-asking breaks trust and flowGreetings and small talk
Order number, item, amounts paidMoney decisions depend on exact numbersDead ends already ruled out
Decisions made and promised actionsStops repeat questions and contradictionsLong explanations already given
Policy limit for this case ($500 auto refund)Stops limits leaking in from other casesGeneral 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.
  1. Copy the block. Add one field Pine needs for escalations.
  2. Write the update rule for that field: what source fills it, and when.
  3. 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.

What to notice

Next: what this looks like in real teams, then the traps.

Field note, November 2026

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

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.

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".