Domain 5 · Context Management & Reliability
This domain is about keeping an agent's memory, errors and sources trustworthy: what to keep in context, when to escalate, how subagents report failure, and how to keep track of where each claim came from.
Key terms: Context window: everything Claude can see at once. Summarization: shrinking earlier conversation into a shorter version. Escalation: handing a case to a human. Provenance: where each piece of information came from. Confidence score: how sure a system says it is.
5.1 Manage conversation context to preserve critical information across long interactions
What it is: Claude can only use what is in its context window, and that fills up and gets summarized as a conversation grows. Summaries blur exact numbers, details in the middle of long inputs are easy to miss, and bulky tool results waste space. The fix is to keep key facts in a short, separate block and trim everything else.
The exam tests: how context gets lost or diluted, and how to protect the facts that matter. Video: Ep 18.
Attention dips in the middle of the context
| Where in the context | How well the model attends |
|---|---|
| Beginning (system prompt, first message) | Strong |
| Middle | Blind spot |
| End (most recent messages) | Strong |
A PostToolUse hook keeps about 20 of 400 tokens
Full notes
Rule: The API is stateless, so every request must carry the complete conversation history.
Rule: Progressive summarization turns exact numbers, percentages, dates and customer expectations into vague summaries.
Rule: The lost-in-the-middle effect: models handle the start and end of a long input well and may skip findings in the middle. Put key findings at the beginning of combined inputs, and organize details under explicit section headers.
Rule: Tool results pile up and eat tokens out of proportion to their value, for example 40 or more fields per order lookup when 5 matter. Trim verbose output to the relevant fields before it accumulates.
Rule: Keep a persistent "case facts" block (amounts, dates, order numbers, statuses) in every prompt, outside the summarized history. In multi-issue sessions, keep structured issue data in a separate layer.
Rule: Require subagents to return metadata (dates, source locations, methodology) in structured output. When downstream agents have small context budgets, have upstream agents return key facts, citations and relevance scores instead of long reasoning.
Deep dive
- Ep 18 at 07:47: how summarization loses numbers.
- Ep 18 at 11:42: the lost-in-the-middle blind spot.
- Ep 18 at 22:05: the case facts block.
- Ep 18 at 25:08: trimming tool results first.
5.2 Design effective escalation and ambiguity resolution patterns
What it is: Escalation means handing a case to a human. An agent should do it when the customer asks for one, when the policy does not cover the situation, or when it is stuck. A customer's mood, or the agent's own confidence score, are poor signals.
The exam tests: the right triggers for handing a case to a human, and the wrong ones. Video: Ep 18.
Escalate on requests, gaps and stalls, not on mood or confidence
| Escalate when | Do not escalate on |
|---|---|
| Customer explicitly asks for a human | Frustrated tone on its own |
| Policy is silent or has a gap | Self-reported confidence score |
| Agent cannot make meaningful progress | Task complexity on its own |
Several customer matches? Ask for another identifier; never pick one by heuristic.
Full notes
Rule: Escalate when the customer explicitly asks for a human, when policy is silent or has a gap on the request, or when the agent cannot make meaningful progress.
Rule: Honor an explicit request for a human straight away, without investigating first.
Rule: If the issue is straightforward and within the agent's reach, acknowledge the frustration and offer a resolution. Escalate only if the customer repeats their preference.
Rule: Sentiment and self-reported confidence scores are unreliable stand-ins for how complex a case really is.
Rule: When a lookup returns several matches, ask for another identifier. Do not choose by heuristic.
Rule: Put explicit escalation criteria, with few-shot examples, into the system prompt.
Deep dive
- Ep 18 at 29:33: the escalation triggers.
- Ep 18 at 31:25: why negative sentiment alone is not a trigger.
- Ep 18 at 35:29: the policy gap trigger.
- Ep 18 at 42:50: triggers and traps in one summary.
5.3 Implement error propagation strategies across multi-agent systems
What it is: In a multi-agent system, a subagent that fails should report what happened, what it tried, any partial results and what could be tried next, so the coordinator can decide. It fixes small problems itself first, and never hides a failure by returning an empty result as if it had worked.
The exam tests: what a subagent should report when something fails, and what it should not hide. Video: Ep 19.
An ideal error response includes:
- Error category
- Whether it is retryable
- The query that was attempted
- Partial results and alternatives
Full notes
Rule: Structured error context (failure type, attempted query, partial results, alternatives) lets the coordinator choose a recovery.
Rule: An access failure, such as a timeout, needs a retry decision. A valid empty result is a successful query that found no matches.
Rule: Subagents recover locally from transient failures. They pass up only what they cannot resolve, with what was attempted and the partial results.
Rule: Synthesis output should carry coverage annotations: which findings are well supported, and which topics have gaps because sources were unavailable.
Deep dive
- Ep 19 at 05:26: a structured error.
- Ep 19 at 15:37: access failure versus empty result.
- Ep 19 at 19:33: silent suppression.
- Ep 19 at 23:27: local recovery before escalating.
5.4 Manage context effectively in large codebase exploration
What it is: In a long session on a big codebase, Claude gradually loses track of what it found earlier. You keep it on track by writing key findings to a scratchpad file, using /compact to shrink the conversation, and saving agent state in a manifest file so work can resume after a crash.
The exam tests: how to keep a long exploration coherent, and how to recover after a crash. Video: Ep 19.
Handle silent failures in three layers
Full notes
Rule: In long sessions, context degrades. Answers become inconsistent, and the model refers to "typical patterns" instead of the specific classes it found earlier.
Rule: A scratchpad file records key findings on disk, outside the context window. Tell Claude to use it, and add it to CLAUDE.md for pipelines.
Rule: Send subagents to answer specific questions ("find all test files", "trace the refund flow") while the main agent keeps the high-level picture.
Rule: Summarize one exploration phase before you start the next, and inject that summary into the new agents' context.
Rule: For crash recovery, each agent exports its state to a known location (a manifest). The coordinator loads the manifest on resume and injects it into the agents' prompts.
Rule: /compact reduces context use when it fills with verbose discovery output, keeping the highlights.
Deep dive
- Ep 19 at 25:41: context degradation.
- Ep 19 at 29:09: scratchpad files.
- Ep 19 at 29:32: the manifest file.
- Ep 19 at 35:02: the
/compactcommand.
5.5 Design human review workflows and confidence calibration
What it is: Even when an automated system is 97% accurate overall, it can be weak on one type of document. You find out by sampling results from each group and by checking confidence scores against known answers. Low-confidence or unclear cases go to a human reviewer.
The exam tests: how to measure real accuracy and decide where humans look. Video: Ep 20.
Full notes
Rule: A high overall accuracy, such as 97%, can hide poor results on specific document types or fields.
Rule: Stratified random sampling of high-confidence extractions measures the true error rate and reveals new error patterns.
Rule: Field-level confidence scores must be calibrated with labeled validation sets. Raw model confidence is not enough.
Rule: Check accuracy by document type and by field before you reduce human review.
Rule: Send low-confidence extractions, and those with ambiguous or contradictory sources, to human review. This focuses limited reviewer time.
Deep dive
- Ep 20 at 02:00: the 97% accuracy problem.
- Ep 20 at 09:23: stratified sampling.
- Ep 20 at 14:52: field-level confidence scores.
- Ep 20 at 19:49: calibration.
5.6 Preserve information provenance and handle uncertainty in multi-source synthesis
What it is: When Claude combines findings from several sources, it can lose track of which claim came from where. The fix is to carry each claim together with its source and its date through every step, and when two sources disagree, to show both instead of choosing one.
The exam tests: how to keep every claim tied to its source, and what to do when sources disagree. Video: Ep 20.
Provenance is most at risk at the synthesis step
Full notes
Rule: Source attribution is lost when findings are compressed in a summary step without claim-source mappings.
Rule: Subagents output structured claim-source mappings (source URLs, document names, relevant excerpts). Downstream agents must preserve and merge them.
Rule: When credible sources give conflicting statistics, annotate the conflict with source attribution. Do not pick one. The coordinator decides how to reconcile them.
Rule: Require publication or collection dates in structured outputs, so a difference over time is not mistaken for a contradiction. This is a schema fix: dates are required fields. Prompt tuning and retry logic do not fix it.
Rule: Structure reports to separate well-established findings from contested ones. Match the format to the content: tables for financial data, prose for news, structured lists for technical findings.
Deep dive
- Ep 20 at 25:45: the attribution problem.
- Ep 20 at 31:22: conflicting statistics.
- Ep 20 at 34:45: temporal data.