5.1 Managing Conversation Context
5.1.1 The Problem With Long Conversations
Domain 5 is about reliability — making agents behave correctly over the long haul. Task Statement 5.1 starts with a problem every long conversation hits: the context window fills up. Recall from Domain 1 that the API is stateless, so every request carries the full history — and as a customer-support chat or a multi-hour session grows, that history gets large. The instinct is to SUMMARIZE older parts to save room. And that instinct, applied carelessly, quietly destroys the very details the agent needs.
Here's the danger, made concrete. Early in a support chat the customer says: '$247.83 was charged for order #8891 on March 3rd.' Summarize that history and it becomes 'the customer wants a refund for a recent order.' The exact amount, the order number, the date — gone. Later, when the agent needs to process that refund, it no longer knows the amount or which order. Progressive summarization is like turning a detailed receipt into the note 'bought some stuff' — fine for the gist, useless when you need the specifics.
This lesson is about managing context so the critical facts SURVIVE. The central technique is elegant — pull the hard facts OUT of the summarizable history into a protected block — and there's a second effect (where in a long input the model actually pays attention) that shapes how you arrange things. Let's build both up.
Progressive summarization condenses away transactional specifics — amounts, order numbers, dates — exactly the facts the agent later needs to act. Like turning a receipt into 'bought some stuff.'
The one idea to hold onto
In long conversations, progressive summarization destroys transactional specifics (amounts, dates, IDs, customer-stated expectations). The fix is to keep those facts in a protected block that is NEVER summarized.
5.1.2 The Persistent Case-Facts Block
Here is the single most important pattern in this lesson. Instead of trusting summarization to preserve the important details, you EXTRACT the transactional facts — customer ID, order numbers, amounts, dates, statuses — into a structured 'case facts' block, and you include that block in EVERY prompt, OUTSIDE the summarized history, where it is NEVER summarized. The history can be condensed freely to save space; the case facts ride alongside it, always intact, always exact.
Think of it as a sticky note on the case file. The long conversation is the file — you can skim, summarize, and compress it. But the sticky note on the front always shows the essentials: customer ID, order #8891, $247.83, charged March 3rd, status: disputed. No matter how much the file is condensed, the sticky note is untouched, so the agent never loses the facts it needs to act. This pattern resolves the tension from Domain 1.1: the API is stateless and you want to trim history to save tokens, but trimming would lose facts — so you protect the facts separately and trim the rest freely.
For multi-issue sessions (a customer with several problems at once), the same idea scales: extract each issue's structured data — order IDs, amounts, statuses — into a separate context layer so none of them gets blurred together during summarization. The principle is constant: identify the facts that must survive, and give them a home outside the part you compress.
5.1.2 — Key Concept
Extract transactional facts (customer ID, order #, amounts, dates, statuses) into a persistent 'case facts' block included in EVERY prompt, OUTSIDE the summarized history and never summarized — like a sticky note on the case file. Trim the history freely; the facts always survive.
5.1.3 Lost in the Middle, and Trimming Tool Output
A second effect shapes how you ARRANGE a long input: 'lost in the middle.' Models reliably attend to information at the BEGINNING and the END of a long input, but are more likely to overlook things buried in the MIDDLE. It's like a long meeting — people remember how it opened and how it closed, but the bit in the middle blurs. So WHERE you place information matters: put key findings and the case-facts block at the START, use explicit section headers and clear boundaries so important content stands out, and don't bury something critical in the middle of a wall of text.
The third practice attacks bloat at the source: tool-result trimming. Tool outputs accumulate in context and consume tokens out of all proportion to their relevance — an order lookup might return 40+ fields when only 5 matter for a return. Trim each tool result down to the relevant fields BEFORE it enters the conversation history, rather than letting the full payload pile up. This keeps the context lean so the facts that matter aren't crowded out — and it pairs naturally with the case-facts block (extract what matters, discard the rest).
| Technique | What it does |
|---|---|
| Case-facts block | Protects transactional facts from summarization |
| Front-load key info | Beats 'lost in the middle' — start/end get attention |
| Section headers / boundaries | Make important content stand out in a long input |
| Trim tool results | Keep only relevant fields before they enter history |
Four context-management moves: protect the facts, place them where the model attends, structure for visibility, and trim verbose tool output at the source.
5.1.3 — Key Concept
'Lost in the middle': models attend to the beginning and end of long inputs and may miss the middle — front-load key findings and use clear section headers. And trim verbose tool results to relevant fields BEFORE they accumulate in history.
5.1.4 The Exam Traps
The 5.1 traps test whether you protect critical facts rather than trusting summarization, and whether you account for position effects and tool bloat.
- •Trusting summarization. ✗ Assuming progressive summarization safely preserves details. ✓ It destroys transactional specifics — use a persistent case-facts block.
- •Prompt reminders for position. ✗ Telling the model 'pay attention to everything' to fix lost-in-the-middle. ✓ Use STRUCTURE — front-load key info, add section headers.
- •Keeping full tool results. ✗ Letting 40-field tool payloads accumulate in history. ✓ Trim to the relevant fields before they enter context.
- •Selective truncation that loses facts. ✗ Truncating history in a way that drops the amounts/dates. ✓ Protect facts in the case-facts block, then trim the rest.
5.1.4 — Exam Trap
✗ Trusting summarization to keep specifics; ✗ prompt reminders to fix 'lost in the middle' (use structure/position instead); ✗ retaining full verbose tool results. ✓ Persistent case-facts block (never summarized), front-loaded key info with headers, and trimmed tool outputs.
5.1.5 Put It Together: Preserve What Matters
You now know why summarization loses critical facts, the persistent case-facts block, the lost-in-the-middle effect, and tool-result trimming. The exercise has you build the case-facts pattern and feel how it survives aggressive summarization.
5.1.5 — Build Exercise (30 min)
(1) Run a long support conversation and let history be progressively summarized; confirm transactional details (amount, order #, date) get lost. (2) Add a persistent case-facts block — extract those facts into a structured block included in every prompt, outside the summarized history — and confirm they survive. (3) Deliberately bury a key instruction in the middle of a long input and observe it being overlooked; then move it to the start with a section header and confirm it's used. (4) Trim a 40-field tool result down to the 5 relevant fields before it enters history and note the context saved.
Protecting facts keeps a long conversation reliable. The next lesson, 5.2, turns to a different reliability decision: when an agent should resolve a request itself versus escalate it to a human.
Where this shows up on the exam
5.1 questions describe lost details in long conversations or position effects. The answers are the case-facts block (never summarized), front-loading with structure for lost-in-the-middle, and trimming tool results — not 'summarize more carefully' or 'remind the model.'
Key Takeaways
- ✓In long conversations, progressive summarization destroys transactional specifics — amounts, percentages, dates, order numbers, customer-stated expectations.
- ✓The key pattern: extract transactional facts into a persistent 'case facts' block included in EVERY prompt, OUTSIDE the summarized history and never summarized — a sticky note on the case file.
- ✓The case-facts block resolves the stateless-API tension: trim the history freely to save tokens while the protected facts always survive.
- ✓'Lost in the middle': models reliably attend to the beginning and end of long inputs but may miss the middle — front-load key findings and use explicit section headers.
- ✓Fix position effects with STRUCTURE (placement, headers, boundaries), not prompt reminders to 'pay attention.'
- ✓Trim verbose tool results to the relevant fields BEFORE they enter history — outputs accumulate and consume tokens disproportionately (40+ fields when 5 matter).
- ✓For multi-issue sessions, extract each issue's structured data into a separate context layer so issues aren't blurred during summarization.
Check Your Understanding
Test what you learned in this lesson.
Q1.In a long support conversation, the agent loses track of the exact refund amount and order number that the customer mentioned early on. What's the most effective fix?
Q2.What is the 'lost in the middle' effect, and how do you mitigate it?
Q3.An order-lookup tool returns 40+ fields but only about 5 are relevant to a return. What should you do?
Q4.Why is a persistent case-facts block better than relying on summarization to preserve key details?
Practice This Lesson