Claude Context Management: Case Facts, Lost-in-the-Middle and /compact
👋 In plain words: Claude only knows what is in the current conversation, and in long conversations important details get lost or blurred. This lesson shows simple habits that keep exact amounts, dates and findings accurate from the first message to the last.
Long conversations and long explorations degrade in predictable ways. The exam tests the patterns that keep critical information intact (Task Statements 5.1 and 5.4).
🔑 Key terms
- Context window: Everything Claude can 'see' at once: the conversation, tool results and instructions. It has a size limit.
- Progressive summarisation: Repeatedly shortening old messages to save space, which can blur exact details.
- Case-facts block: A small, always-included list of the key facts, such as IDs, amounts and dates.
- Lost in the middle: Models pay less attention to information buried in the middle of a long input.
- /compact: A Claude Code command that shrinks the conversation to free up space.
📖 The story in this lesson
A ShopNest customer has a 40-message conversation about a refund. By message 35 the bot remembers 'a refund is pending' but has forgotten it was £184.20, promised by Thursday.
💡 Think of it like this
The context window is a desk. Paper piles up, old sheets get summarised onto sticky notes, and details vanish. A case-facts block is the one index card you keep pinned in the middle of the desk, never summarised and always visible.
⚙️ Progressive summarisation loses precision
Rolling summaries turn “a £184.20 refund on order #A-7710 by Thursday” into “a refund is pending”. Keep a persistent case-facts block — amounts, order IDs, dates, statuses, promises and customer-stated constraints — and include it in every prompt, outside the summarised history.
<case_facts>
customer_id: C-1042 (verified)
order: #A-7710 · refund £184.20 approved · promised by Thu 19 Nov
constraint: technician visits after 17:00 only
</case_facts>
🌍 Real-world example: The £184.20 that became 'a refund'
Asha's bot now keeps a case-facts block, outside the summarised history, in every request. Even on message 40, the exact amount, order and deadline are there.
<case_facts>
order: #A-7710 | refund GBP 184.20 approved | promised by Thu 19 Nov
constraint: deliveries after 17:00 only
</case_facts>🛠️ Trim tool output before it piles up
An order lookup may return 40+ fields when only 5 matter. Trim results to the relevant fields (for example in a PostToolUse hook) before they accumulate in context. Upstream agents should return structured key facts, citations and relevance scores — not long reasoning chains — when downstream context budgets are tight.
🌍 Real-world example: 40 fields when 5 matter
Each lookup_order call returned 40 fields, including warehouse codes and internal flags. After 10 lookups the context was full of noise. A hook now keeps only status, items, total, delivery date and refund eligibility.
🎯 Lost in the middle
Models reliably use information at the beginning and end of long inputs but may miss findings in the middle. Put a key-findings summary first and organise details under explicit section headers. And always send the complete conversation history — the API is stateless.
🌍 Real-world example: The key finding on page 31
A 60-page research summary hid its most important finding in the middle, and the final report missed it. Putting a short 'key findings' list at the top, with clear section headings below, fixed it.
🗂️ Long codebase explorations
- Symptoms of degradation: inconsistent answers, and talk of “typical patterns” instead of the specific classes found earlier.
- Scratchpad files record key findings for later questions.
- Subagents investigate focused questions (“find all test files”) while the main agent keeps the big picture.
- Phase summaries are injected before the next phase begins.
/compactreduces context use when verbose discovery output fills it.- Crash-recovery manifests: each agent exports its state to a known location; on resume the coordinator loads the manifest and injects that state into agent prompts.
🌍 Real-world example: Ravi's scratchpad
During a two-hour exploration of the payment service, Claude starts saying 'typical patterns' instead of naming the real classes it found earlier. Ravi has it write findings to notes/scratchpad.md, runs /compact, and Claude carries on with the exact class names.
🛠️ Try it yourself (about 8 minutes)
- Take a long support or chat thread you have handled.
- Write a case-facts block of 5 lines or fewer: ID, amount, date, status, one constraint.
- Re-read the thread and check that nothing critical is missing from the block.
✅ You are done when: a colleague could act on the case using only your case-facts block.
🧪 Exam-Style Practice Questions
Try these before opening the answers. They use the same scenario style as the real exam.
Question 1. Aggregated subagent results put the key findings in the middle of a 60-page input, and the synthesis misses them. What helps?
- A. Remove the headers
- B. Increase the temperature
- C. Shuffle the order
- D. Put a key-findings summary at the beginning and organise the details under clear section headers
Show answer
Answer: D. It mitigates the "lost in the middle" effect. A, B and C don't address position effects.
Question 2. A long exploration fills context with noisy grep output. Which built-in command reduces context usage?
- A.
/mcp - B.
/init - C.
/compact - D.
/memory
Show answer
Answer: C. D inspects memory files. B bootstraps CLAUDE.md. A manages MCP servers.
Question 3. A downstream agent has a small context budget. What should upstream agents return?
- A. Structured key facts, citations and relevance scores
- B. Raw HTML
- C. Nothing until asked
- D. Full reasoning chains
Show answer
Answer: A. It's compact and preserves what synthesis needs. B and D bloat context. C adds round trips.
📝 Assignment
Do these tasks in order. Each one has a Done when check, so you know when it is complete. The stretch task is optional but close to what the exam expects from an architect. Keep your answers in one notes file or Git repository, and revisit them in your final week of revision together with the cheat sheet in the last lesson of this course.
- Task 1: Design a case-facts block for a support conversation with order ID, amount, deadline and one customer constraint.
✅ Done when: Your block keeps exact amounts, IDs, dates and the customer constraint, and fits in under 80 words. - Task 2: Trim a 40-field API response down to the five fields a refund decision needs.
✅ Done when: Your trimmed response keeps only the five fields the refund decision needs, with names unchanged. - Stretch: run a long Claude Code exploration with a scratchpad file and use /compact when context fills.
✅ Done when: Claude still names the specific classes it found earlier after /compact, using your scratchpad file.
❓ Frequently Asked Questions
🤔 Why do summaries lose important details?
Progressive summarisation compresses exact numbers, dates and promises into vague phrases.
🤔 What is the lost-in-the-middle effect?
Models use the start and end of long inputs more reliably than the middle, so put key findings first.
🤔 What does /compact do?
It reduces context use in Claude Code when verbose output has filled the conversation.
🤔 How do multi-agent systems recover from a crash?
Each agent exports its state to a known location, and the coordinator reloads a manifest on resume.
🏁 Summary
- Case facts live outside the summary, in every prompt.
- Trim tool output; summarise key findings first.
- Scratchpads, subagents, /compact and manifests keep long work accurate.
Next, continue with Escalation Rules and Error Propagation in Claude Agents.
Independent study material by SQA Tools. Not affiliated with, endorsed by or sponsored by Anthropic. Claude is a trademark of Anthropic. Mock questions are original practice items, not real exam content. Exam facts checked against Anthropic's official exam guides and certification FAQ on 11 November 2026.