Lesson 13 · Domain 5 — Context Management & Reliability (15% of exam)

Preserving Context & Calibrating Escalation

The final domain, and the lightest-weighted at 15% — but don't mistake that for "less tested carefully." These two task statements come up constantly disguised inside the other four domains' scenarios, because context and reliability problems are what production actually looks like.

Lost in the middle

Models reliably attend to the beginning and end of a long input; information buried in the middle is where things get dropped. Progressive summarization compounds this — condensing a conversation's history repeatedly tends to blur exactly the details that matter most: exact amounts, dates, order numbers, what the customer specifically said they expected.

The fix is structural, not "try harder to remember": keep a persistent case-facts block, included verbatim in every prompt, sitting outside whatever gets summarized.

interface CaseFacts {
  orderId: string;
  orderTotal: number;
  orderDate: string;
  customerStatedExpectation: string;
  refundStatus: "none" | "pending" | "processed";
}

function buildPrompt(facts: CaseFacts, history: string, latestTurn: string) {
  return `CASE FACTS (always accurate, do not summarize):
${JSON.stringify(facts, null, 2)}

CONVERSATION SO FAR:
${history}

LATEST MESSAGE:
${latestTurn}`;
}

The same principle applies to tool output: a full order lookup might return 40+ fields when only 5 are ever relevant downstream. Trim before it accumulates in context rather than after — verbose, mostly-irrelevant tool results consume tokens disproportionately to what they're worth, and they're exactly the kind of "middle" content that gets lost anyway.

Escalation: calibrated on the right signals

The official guide's sample question is a direct hit here: an agent achieves only 55% first-contact resolution against an 80% target — because it escalates simple cases (standard damage replacements with photo evidence) while trying to autonomously push through cases that actually need a real policy exception. Both are miscalibration, in opposite directions.

The fix isn't a confidence score or sentiment detection — both are unreliable proxies for actual case complexity, and in this exact scenario the agent is already confidently wrong on the hard cases. The fix is explicit escalation criteria with few-shot examples demonstrating the boundary directly: escalate immediately on an explicit customer request for a human, on a policy gap or exception (not just "this seems hard"), on genuine inability to make progress, or on multiple ambiguous matches that need clarification rather than a guessed selection.

What escalation should never be based on
Sentiment analysis and self-reported confidence scores both fail for the same reason: they measure how the interaction feels, not whether the situation actually requires human judgment or policy authority the agent doesn't have. A calm-sounding customer can have a policy-exception case; a frustrated one can have a trivially resolvable request. Escalate on the objective triggers, not the emotional temperature.

Why this matters beyond the exam

Primary source: Anthropic's Claude API docs and the Agent SDK overview cover context window management directly — this lesson compresses Task Statements 5.1 and 5.2.

Check your understanding

Q1. Your agent achieves only 55% first-contact resolution against an 80% target. It escalates simple cases while trying to autonomously resolve ones needing a real policy exception. What's the most effective fix?
Q2. Why keep a separate "case facts" block instead of relying on the summarized conversation history for order amounts and dates?
Q3. Which of these should NOT be used as an escalation trigger on its own?

Want to sketch escalation criteria for a system you're actually designing? Describe the domain and we'll draft the boundary together.