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

Error Propagation, Scratchpads & Provenance

The last lesson in the core curriculum. Four task statements, all variations on one idea: when something fails or gets uncertain deep inside a multi-agent or long-running system, the information needed to recover has to survive the trip back up — nothing here forgives silence.

Structured error propagation

The official guide's sample question: a web-search subagent times out mid-research. What should it hand back to the coordinator?

interface SubagentError {
  failureType: "timeout" | "not_found" | "rate_limited";
  attemptedQuery: string;
  partialResults: unknown[] | null;
  alternativesToTry: string[];
}

// Bad — hides everything the coordinator could have acted on
function badFailure(): { status: "search unavailable" } {
  return { status: "search unavailable" };
}

// Good — the coordinator can retry smarter, fall back, or proceed with partial data
function reportFailure(q: string): SubagentError {
  return {
    failureType: "timeout",
    attemptedQuery: q,
    partialResults: null,
    alternativesToTry: [`${q} site:reuters.com`, `${q} 2025`],
  };
}

Three anti-patterns to name on sight: a generic status string that hides useful context; silently suppressing the error by returning an empty result marked as success (which looks identical to "the query legitimately found nothing"); and terminating the entire workflow on one subagent's failure, when a partial-results recovery might have been entirely viable. Subagents should handle transient failures locally when they can, and only propagate upward what they genuinely couldn't resolve — along with what was attempted and whatever partial results exist.

Scratchpads and manifests for long-running work

Extended exploration sessions degrade: the model starts giving vaguer answers, referencing "typical patterns" instead of the specific classes it actually found earlier. Two counters: delegate verbose exploration to subagents so the main agent coordinates at a high level instead of drowning in raw output, and maintain scratchpad files recording key findings that later steps can reference directly instead of relying on what's still in context. For crash recovery specifically, have each agent export its state to a known location, and have the coordinator load a manifest of that state on resume. /compact is the manual release valve when context is filling with exploration output faster than it's being distilled.

Stratified sampling beats aggregate accuracy

"97% accuracy" can hide a document type or field that's actually failing badly, buried inside an average dominated by the easy cases. Stratified random sampling — checking across document types and fields deliberately, not just overall — is what surfaces that. Pair it with field-level confidence scores calibrated against labeled validation data (not self-reported, not vibes), and route low-confidence or contradictory-source extractions to human review before trusting the aggregate number to mean what it looks like it means.

Provenance: don't let synthesis erase where a claim came from

When multiple sources get combined into one report, source attribution is the first casualty of careless summarization. The fix is requiring subagents to output structured claim→source mappings, and requiring the synthesis step to preserve — not flatten — them. When two credible sources genuinely disagree, annotate the conflict with both sources rather than silently picking one. And always carry publication or collection dates through: without them, a real change over time gets misread as a contradiction between sources that were simply talking about different points in time.

The thread connecting all of Domain 5
Every task statement here is a version of the same instruction: don't let information die in transit. Whether it's a case fact lost to summarization, an error reduced to "failed," a finding buried mid-context, or a source attribution dropped during synthesis — the fix pattern is always to carry the specific, structured detail forward explicitly rather than trusting it to survive compression on its own.

Why this matters beyond the exam

Primary source: Anthropic's Agent SDK overview covers scratchpad and session-recovery patterns — this lesson closes Domain 5 and the core curriculum, compressing Task Statements 5.3 through 5.6.

Check your understanding

Q1. A web-search subagent times out mid-research. Which failure-reporting approach gives the coordinator the best shot at recovering?
Q2. An extraction pipeline reports 97% aggregate accuracy. Why isn't that enough to trust it fully?
Q3. Two credible sources report different figures for the same statistic, collected at different times. What's the correct synthesis behavior?

That's every task statement in the official exam guide covered. Ready for a mixed-domain review, or want to talk through the mock-exam plan in Week 4? Just ask.