Lesson 5 · Principal Track · Staff

Architecture Reviews & Production Design

~16 min · 2 modules + the capstone toolkit · the final lesson — where the whole track becomes one reusable reviewing instinct

Published

Context engineeringArchitectureProduction designSemantic searchRetrieval augmented generation

Your bar: walk into any AI architecture review and, within a minute, name the context strategy (pre-indexed vs read-on-demand vs none), name its failure mode, and prescribe the right retrieval for the data type. This capstone gets you fluent on real products (Cursor, Claude Code, ChatGPT, Copilot) and production agents (billing, support, engineering, research), then hands you the Principal’s toolkit: a cheat sheet, mental models, checklists, and interview banks you keep. 1

The whole capstone collapses to one reviewing reflex. Each chip is one move you’ll make on sight:

Every assistant is a context strategy + a model

name the strategy: pre-index · read-on-demand · none

and you’ve named its failure mode

then match retrieval to the data type

Every assistant lives on one spectrum PRE-INDEXED (embeddings) READ-ON-DEMAND (tools) Cursorrepo embeddings Copilotopen files + index ChatGPThistory + connectors Claude Codegrep / glob / read …and each position picks its own way to fail Pre-indexed: stale index · retrieves a topically-similar but wrong file · misses exact identifiers Read-on-demand: latency & token cost from round-trips · misses a file it never thought to grep History / none: weak grounding in live systems · hallucinates when nothing was retrieved
The reviewer's first move on any AI product: place it on the pre-indexed ↔ read-on-demand spectrum. Position predicts failure mode — staleness on the left, missed-grep and cost on the right, hallucination at the "none" extreme. Product specifics here are at time of writing and version-dependent.4
11

Architecture Reviews — Reading Real AI Products

You can’t review what you can’t name. Each product below is a context strategy with a model attached. Name the strategy first; its strengths, weaknesses, and failure mode follow from there.

The four products, side by side

ProductContext strategyStrengthsWeaknessesSignature failure
CursorPre-indexed embeddings of the repo + semantic retrieval (+ open files)Fast recall across huge repos; finds code before you know the filenameIndex staleness; embeddings miss exact identifiersRetrieves a topically-similar but wrong file
Claude CodeAgentic read-on-demand via tools (grep / glob / read); follows the dependency graph live; no persistent indexAlways fresh; precise; transparent about what it readMore tool round-trips → latency & token cost; depends on choosing good searchesMisses a file it never thought to grep
ChatGPTConversation history + optional retrieval / uploads / connectors / a memory featureBroad general capability; cross-session memoryWeak grounding in your live systems without connectorsHallucinates when nothing was retrieved
GitHub CopilotOpen files + nearby code + (newer) repo / workspace indexing for chatVery low-latency inline local contextHistorically a limited window of surrounding code; weaker whole-repo reasoningSuggests plausible code that ignores a distant constraint
Pre-index (Cursor) Builds embeddings ahead of time so retrieval is one fast lookup. The bet: precompute relevance. The tax: an index drifts from reality the moment code changes.
Read-on-demand (Claude Code) No precompute; it searches the live tree per task. The bet: always-fresh, auditable reads. The tax: round-trips cost tokens and latency, and a bad search plan misses files.
History + connectors (ChatGPT) Strong generalist whose grounding in your systems is only as good as the connectors you wire up. With nothing retrieved, it fills gaps confidently.
Local window (Copilot) Optimised for instant inline completion from what’s near the cursor; whole-repo constraints far from the cursor can be silently violated.

Same query, two strategies

Pre-indexed (embeddings) Read-on-demand (tools) query → embed vector lookup (1 hop) top-k chunks fast · but as stale as the index & blind to exact identifiers grep / glob read → follow imports grep again (N hops) fresh & precise · but more round-trips, and misses unsearched files
One hop versus N hops. Pre-index trades freshness for speed; read-on-demand trades speed for freshness and transparency. Neither is "better" — they fail differently, and the review names which failure your use-case can't tolerate.3
✗ “Cursor is smarter than Copilot” (or vice-versa).
✓ They picked different context strategies. “Smarter” is use-case dependent: huge-repo recall vs instant local completion vs always-fresh precision.
✗ “An embedding index means it always finds the right code.”
✓ Embeddings retrieve by topical similarity; they can miss an exact identifier and surface a plausible-but-wrong file. Hybrid + rerank exists for exactly this.
📥 Memory rule: Every assistant is a context strategy with a model attached. Name the strategy — pre-index vs read-on-demand vs none — and you’ve named its failure mode.
Memory check
  • What’s Cursor’s signature failure, and why? → retrieves a topically-similar but wrong file — embeddings match meaning, not exact identifiers; index can also be stale
  • What does Claude Code trade for always-fresh context? → more tool round-trips → higher latency and token cost; relies on choosing good searches
  • When does a history/connector assistant hallucinate most? → when nothing relevant was retrieved and it isn’t grounded in your live systems
You’re reviewing a vendor’s “AI code assistant.” What’s the first question you ask, and why?

Hit these points: “What’s the context strategy — pre-indexed embeddings, read-on-demand tools, or just history?” → that single answer predicts strengths, cost shape, and the failure mode → pre-index → ask about index freshness/invalidation and identifier recall; read-on-demand → ask about round-trip latency and search-coverage gaps; history/none → ask what grounds it in live systems → then ask if there’s hybrid + rerank to cover the embedding blind spot → frame: I’m not comparing models, I’m comparing retrieval architectures.

12

Production Design — Match Retrieval to the Data

A production agent is a context pipeline. The senior move is choosing the retrieval mechanism by data type: exact & financial → structured query; fuzzy & textual → hybrid + rerank; volatile → fetch live; long-running → compress + remember.

The generic production context pipeline

Every production agent is this pipeline ingest index /store retrieve assemble guardrails LLM log The magenta stages — retrieve & assemble — are where data type dictates the mechanism. Guardrails defend against poisoned/injected context; the log makes the whole call auditable.
The pipeline is constant; the retrieve stage changes per agent. Get that one stage wrong for the data type and no amount of model or prompt fixes it.8

Four agents, four data shapes

AgentRetrieval (matched to data)ScalabilityCostReliabilityObservability
BillingDeterministic structured query — SQL keyed by account_id, never fuzzy embeddingsCheap point lookupsLow tokensNo hallucinated numbers; never invent amountsLog every assembled context + tool call for audit
SupportHybrid over help-center KB + customer history (memory); rerankKB grows; cache hot articlesModerateKB freshness; PII handling / complianceRetrieval hit-rate; deflection/escalation; cite sources to user
EngineeringCodebase retrieval (hybrid + structural) and/or read-on-demand; tests as a grounding signalLarge repos; token-heavyToken cost dominatesGround in real code; run testsLog which files / symbols loaded per task
ResearchMulti-source web/doc retrieval, multi-step; compress intermediate findings; keep citationsMany calls / sourcesHigh (fan-out)Adversarial verification; dedupe conflicting sourcesSource provenance per claim
Billing — exact Financial data must be exact and auditable. A SQL point-lookup returns the true number; a semantic search returns the most-similar number — which is a bug. Match mechanism to data type.
Support — fuzzy Natural-language KB articles are the home turf of hybrid retrieval + rerank, with customer history as memory. Cache hot articles; cite sources back to the user.
Engineering — structural Code has structure (imports, symbols, tests). Hybrid + structural retrieval or read-on-demand grounds answers in real code; tests are a verification signal the agent can run.
Research — volatile Truth is spread across many fresh sources. Fan out, verify adversarially, compress intermediate findings to fit the budget, and keep provenance per claim.
✗ “Just use vector search for everything — it’s the AI way.”
✓ Vector search returns the most similar, not the correct. For exact/transactional data (an invoice total) you need a deterministic structured query, not semantic similarity.
✗ “We’ll add observability later — ship the agent first.”
✓ Without logging the assembled context per call, a wrong answer is undebuggable. For billing it’s also non-negotiable for audit. Observability is part of the design, not a follow-up.
📥 Memory rule: Design the retrieval to the data: exact & financial → structured query; fuzzy & textual → hybrid + rerank; volatile → fetch live; long-running → compress + remember.
Memory check
  • Why is embedding search wrong for a billing agent? → it returns the most-similar value, not the exact one; financial data needs deterministic, auditable structured queries
  • What’s the dominant cost driver for an engineering agent? → tokens — large repos mean token-heavy context; cost scales with what you load per task
  • What does a research agent need that a billing agent doesn’t? → adversarial verification, dedupe of conflicting sources, and source provenance per claim across a fan-out
Design the retrieval layer for a billing-support agent that must quote exact charges. Walk the trade-offs.

Hit these points: charges are exact, transactional, auditable → retrieve via deterministic SQL keyed by account_id/invoice id, not embeddings → embeddings would return the most-similar amount, i.e. a confidently-wrong number → reliability rule: the agent may quote only values it pulled, never synthesize amounts → log every assembled context + tool call for audit and dispute resolution → if the user also asks policy questions, that’s a different data type → layer hybrid KB retrieval for the textual part → one agent, two retrieval mechanisms matched to two data types.

Interview — pick your bar

Answer out loud in ~60s, then reveal. Core = recall · Senior = trade-offs & failure modes · Staff = synthesis under ambiguity · System Design = open design round (a different axis, not a harder level).

Name each product's context strategy: Cursor, Claude Code, ChatGPT, GitHub Copilot.
Hit these points: Cursor = pre-indexed embeddings of the repo + semantic retrieval (plus open files) → Claude Code = agentic read-on-demand via tools (grep / glob / read), follows the dependency graph live, no persistent index → ChatGPT = conversation history + optional uploads / connectors / memory → GitHub Copilot = open files + nearby code, with newer repo/workspace indexing for chat → the frame: each is a context strategy with a model attached, and the strategy — not the model — is what you're naming.
What is the pre-indexed ↔ read-on-demand spectrum, and where do those four products sit on it?
Hit these points: the axis is when retrieval happens — precompute an index ahead of time vs search the live source per task → pre-indexed (left): Cursor builds embeddings up front so retrieval is one fast lookup → read-on-demand (right): Claude Code searches the live tree each task, always fresh → Copilot is local-window-plus-index (left-of-centre), ChatGPT is history/connectors which is "none-to-shallow" grounding → placing a product on the axis is the reviewer's first move because position predicts the failure mode.
Match each production agent to the retrieval its data type demands: billing, support, engineering, research.
Hit these points: billing = exact/transactional → deterministic structured query (SQL keyed by account_id), never embeddings → support = fuzzy natural-language KB + customer history → hybrid + rerank, cite sources → engineering = structured code (imports, symbols, tests) → hybrid + structural retrieval or read-on-demand, run tests as a grounding signal → research = volatile, multi-source → fan-out web/doc retrieval, compress intermediate findings, keep provenance per claim → the rule underneath: match the retrieval mechanism to the data type.
Define agent, runtime, and RAG as you'd use them in a production-design review.
Hit these points: an agent is an LLM that uses tools to act, not just generate text → the runtime is the orchestration layer around it — it wires tools, retrieval, memory, and the loop that feeds context in and reads results back → RAG is the pattern retrieve → assemble → LLM → answer, so the answer is grounded in fetched facts rather than the model's parametric memory → in a review these let you separate "what does the model see" (RAG/retrieve) from "what can it do" (agent/tools) from "who assembles it" (runtime).
Cursor and Claude Code use opposite strategies. Name each one's signature failure mode and why position on the spectrum causes it.
Hit these points: Cursor (pre-indexed) fails by retrieving a topically-similar but wrong file — embeddings match meaning, not exact identifiers — and by serving a stale index after code changes → that's the structural tax of precompute: the index drifts from reality the moment the repo moves → Claude Code (read-on-demand) fails by missing a file it never thought to grep, and pays more tool round-trips → latency & token cost → that's the tax of searching live: freshness is bought with hops and a dependence on a good search plan → neither is "better"; the review names which failure your use-case can't tolerate.
Why is semantic embedding search the wrong retrieval for a billing agent, and what does the right design cost you?
Hit these points: embeddings return the most-similar value, not the correct one — for a charge that means a confidently-wrong amount with no audit trail → financial data is exact, transactional, and disputable, so it needs a deterministic structured query keyed by account_id/invoice id → the design rule: the agent may quote only values it pulled, never synthesize a number → the cost you accept is less "magic" — you can't fuzzily match a vaguely-worded question to a row, so you invest in intent parsing and exact keys → and you must log the assembled context per call, which billing needs anyway for audit and dispute resolution.
A research agent fans out across many sources. Which failure modes does that shape invite, and how do you defend each?
Hit these points: conflicting — sources disagree and the model silently picks one → dedupe, prefer authoritative sources, surface the conflict rather than hide it → outdated — fetch live for volatile facts, don't lean on a stale cache → excessive — fan-out blows the budget and buries signal ("lost in the middle") → compress intermediate findings before assembly → cost: fan-out multiplies calls, so cap breadth and cache repeated lookups → reliability: adversarial verification of claims → observability: source provenance per claim so any sentence is traceable to where it came from.
"We'll add observability later — ship the agent first." Push back like a reviewer.
Hit these points: without logging the assembled context per call, a wrong answer is undebuggable — there's no stack trace pointing at "wrong document retrieved" → you can't tell a retrieval bug (wrong context in) from a reasoning bug (right context, bad answer), so you can't decide whether to fix retrieval or the model → for billing it's not optional: audit and dispute resolution legally require the trail → observability is a design property of the retrieve/assemble stages, not a follow-up sprint → minimum bar: log what was retrieved and assembled per call, plus retrieval hit-rate, before launch.
You're reviewing an unfamiliar vendor "AI assistant" with 20 minutes. What's your line of questioning, and what would make you walk away?
Hit these points: first question is always "what's the context strategy — pre-indexed embeddings, read-on-demand tools, or just history?" — that one answer predicts strengths, cost shape, and failure mode → pre-indexed → probe index freshness/invalidation and exact-identifier recall → read-on-demand → probe round-trip latency and search-coverage gaps → history/none → ask what grounds it in our live systems → then: is retrieval hybrid + reranked to cover the embedding blind spot, and is retrieval evaluated (recall@k) not just answers? → walk away if there's no observability of assembled context and no answer on freshness — that's an undebuggable, stale-by-default system → frame throughout: I'm comparing retrieval architectures, not models.
Build vs buy: a VP asks whether to adopt a vendor assistant or build our own retrieval. Make the principal-level call.
Hit these points: decide by where the differentiation lives — buy when the data is generic and the vendor's context strategy already fits the use-case; build when our edge is the retrieval over proprietary data the vendor can't reach → the model is a commodity any competitor can rent; the retrieval pipeline over our live systems is the moat → the pivot question: does off-the-shelf grounding actually reach our systems, or does it hallucinate without connectors? → sequence it: instrument the failing cases first — if the gap is retrieval coverage, no vendor model upgrade closes it → hybrid stance is common: buy the model/runtime, build the retrieval and evaluation that compound across every feature.
Across billing, support, engineering, and research agents, where does retrieval investment actually pay off — and where would you NOT over-invest?
Hit these points: investment compounds where wrong answers carry the highest business/compliance risk and where the data is yours — billing (audit/dispute exposure) and engineering (proprietary code) reward deep, exact retrieval → support rewards hybrid + rerank plus caching hot articles, because volume and deflection make small accuracy gains pay back fast → research rewards verification and provenance more than index sophistication, since freshness beats precompute on volatile sources → where not to over-invest: building a bespoke embedding stack for generic data a vendor already serves, or chasing a model upgrade (a flat tax on every call) to paper over a retrieval gap → the staff move: instrument, attribute failures by class, and put the build effort where it compounds across features rather than where it's merely fashionable.
Design-round framework — drive any production context-system prompt through these, out loud:
  1. Clarify the data type first — exact/financial, fuzzy text, structural code, or volatile multi-source — because it dictates the retrieval mechanism.
  2. Place it on the spectrum: pre-index (fast, can go stale) vs read-on-demand (fresh, more round-trips) vs fetch-live for volatile/exact data.
  3. Retrieve: recall first — lexical (BM25) + semantic, hybrid — then rerank for precision; structured query where data is exact.
  4. Assemble within budget; compress long runs; reserve fixed space for history and the answer.
  5. Reliability & guardrails: no-synthesis rule for exact data, adversarial verification for research, injection/PII defense before the model.
  6. Cost & scale: tokens are the bill — tighter selection, caching hot retrievals, cap fan-out.
  7. Observability: log assembled context + tool calls per call; track retrieval hit-rate and the five failure modes separately from answer accuracy.
Design the context system for a billing assistant that quotes exact charges and also answers billing-policy questions.
A strong answer covers: spot two data types in one product → charges are exact/transactional/auditable → deterministic SQL keyed by account_id/invoice id, never embeddings, because a semantic match returns the most-similar amount — a confidently-wrong number → policy is fuzzy natural-language text → hybrid retrieval + rerank over the help-center KB, with citations → one agent, two retrieval mechanisms matched to two data types → reliability rule: figures are quoted from a pulled record, never synthesized → guardrails: PII redaction and access control at the retrieve stage, injection defense on KB content → observability: log every assembled context + tool call for audit and dispute resolution → name the failure modes the naive "vector DB for everything" design invites: wrong (similar-not-correct amounts) and outdated (stale figures) → close with freshness: invalidate on write since balances and policies change.
Design the context system for a research agent that fans out across many sources and must produce a cited answer.
A strong answer covers: the data is volatile and spread across many fresh sources, so fetch live rather than rely on a precomputed index → orchestration: a planner decomposes the question, fans out retrieval across web/docs/APIs, each sub-step returning candidates → recall wide then rerank per sub-question; dedupe near-identical sources → compress intermediate findings into a running summary so the budget survives the fan-out, but keep a citation handle on every retained fact → reliability: adversarial verification — cross-check claims against independent sources and surface conflicts instead of silently picking one → provenance per claim so the final answer is traceable sentence-by-sentence → cost is the dominant constraint — cap breadth, cache repeated lookups, and stop when marginal sources stop changing the answer → observability: log the source set, what each sub-step retrieved, and which claims survived verification → name the failure modes this shape invites: conflicting, outdated, excessive — and the defense for each.

The Principal’s toolkit — your 9 take-home deliverables

Compact, visual revision artifacts. Skim them before a review or an interview; each one is a tool you keep.

1 · One-page Context Engineering cheat sheet

The window A fixed token budget shared by prompt, tools, history, retrieved context, and the answer. A bigger window raises the ceiling; it doesn’t fix what you put in it.

Context = the new query Retrieval/assembly plays SQL’s role: it decides what the model ever sees.

Selection → retrieve Lexical (BM25) · semantic (embeddings) · hybrid; recall first.

Rerank Precision second: re-order the recalled set so the best lands near the top.

Chunking Split on meaning, add overlap; add per-chunk context so a chunk stands alone.

RAG retrieve → assemble → LLM → answer; the answer is grounded in the fetched facts.

Memory vs KB Memory = per-user/session state you carry; KB = shared corpus you retrieve from.

Compression For long runs: summarize/prune intermediate context to stay in budget.

The 5 failure modesIn one line
MissingThe needed fact was never retrieved.
WrongTopically-similar but incorrect context retrieved.
OutdatedStale index/doc; reality has moved on.
ConflictingTwo sources disagree; model picks one silently.
ExcessiveToo much noise; signal buried, cost up, “lost in the middle.”

2 · Context Engineering mental models

Constant vs variable Context is the variable; the model is the constant. Change the context, change the answer.

The new query Context retrieval is the new database query — same role SQL played.

Recall, then precision Cast wide first; rerank to surface the best. Two stages, two jobs.

Match retrieval to data Exact → structured; fuzzy → hybrid; volatile → live; long → compress.

Most AI bugs are context bugs Suspect the input before blaming the model.

The window is RAM A budget you allocate, not a pipe to your data.

3 · Architecture-review checklist

The ten questions to run on any AI design
  • What’s the context strategy? → pre-index · read-on-demand · none
  • Are there recall and precision stages? → retrieve wide, then rerank
  • What’s the chunking strategy? → split on meaning + overlap + per-chunk context
  • How is index freshness / invalidation handled? → or is it stale-by-default?
  • Is retrieval hybrid + reranked? → lexical + semantic covers each other’s blind spots
  • Is retrieval evaluated — not just answers? → hit-rate / recall@k, not vibes
  • Is there a budget / compression plan for long sessions? → summarize, prune, prioritize
  • Can you observe the assembled context per call? → log what was sent, auditable
  • Is each failure mode covered? → missing / wrong / outdated / conflicting / excessive
  • Is PII / compliance handled in retrieval? → redaction, access control, injection defense

4 · Common failure modes — symptom → cause → fix

ModeSymptomRoot causeFix
Missing”I don’t have info on that” / vague answerRelevant doc never retrieved (recall gap)Improve recall: hybrid retrieval, better chunking, more k
WrongConfident answer about the wrong thingTopically-similar but incorrect chunk ranked topAdd rerank; lexical signal for exact identifiers
OutdatedAnswer reflects an old state of the worldStale index / cached docInvalidation on write; or fetch live for volatile data
ConflictingInconsistent answers; arbitrary choiceSources disagree; no resolution policyDedupe, prefer authoritative source, surface the conflict
ExcessiveSlow, costly, “lost in the middle”Too much low-signal context packed inTighten selection; rerank; compress; trim history

5 · Interview questions (Core → Staff)

Core — What is a context window and why can’t an LLM just read the whole codebase?

Hit these points: the window is a fixed token budget — the model’s only channel → real repos are orders of magnitude larger → bigger windows cost more, run slower, and recall the middle poorly → so you must select a relevant subset → the job is “which slice,” not “read it all.”

Core — Lexical vs semantic vs hybrid retrieval — when each?

Hit these points: lexical (BM25) nails exact tokens/identifiers but misses synonyms → semantic (embeddings) matches meaning but misses exact strings and can drift → hybrid runs both and fuses (e.g. reciprocal rank fusion) → rerank then sharpens precision → default to hybrid + rerank in production.

Mid — Walk me through a RAG pipeline and where each failure mode enters.

Hit these points: ingest → chunk → index → retrieve → rerank → assemble → LLM → log → missing enters at retrieve (recall gap), wrong at rerank, outdated at index freshness, conflicting at assemble, excessive at assemble/budget → each stage gets its own metric.

Senior — How do you evaluate retrieval quality, not just answer quality?

Hit these points: build a labeled set of query→gold-doc pairs → measure recall@k and rerank precision separately from end-answer accuracy → log assembled context per call so failures are attributable → a wrong answer with the right context is a reasoning bug; with the wrong context it’s a retrieval bug → you can’t fix what you can’t separate.

Senior — Why is matching retrieval to data type a senior decision?

Hit these points: exact/transactional (a balance) → deterministic structured query; semantic search would return the most-similar, i.e. wrong → fuzzy text → hybrid + rerank → volatile → fetch live, don’t cache stale → long-running → compress + remember → the mistake juniors make is one-size-fits-all vector search.

Staff — Review this design: an AI agent answers finance questions over a vector DB of reports. Pushback?

Hit these points: numbers must be exact and auditable — vector search returns similar, not correct → risk: confidently-wrong amounts, no audit trail → redesign: structured query for the figures, vector/hybrid only for narrative text → add a rule that figures are quoted, never synthesized → log assembled context per call → add freshness/invalidation since reports update → name the failure modes this design currently invites (wrong, outdated).

Staff — Same model, two products, one feels far smarter. Explain to a skeptical interviewer.

Hit these points: the model is the constant; context is the variable → the smarter product retrieves and assembles better context per call → “smart vs dumb” is mostly an artifact of what got loaded → therefore investment goes to retrieval, evaluation, and assembly — not chasing model versions → verify by logging context for the failing cases.

6 · VP Engineering review questions (leadership framing)

VP — Build vs buy: when do we build our own retrieval vs adopt a vendor assistant?

Hit these points: buy when the data is generic and the vendor’s context strategy fits our use-case → build when our differentiation is the retrieval over proprietary data → the model is a commodity; the retrieval pipeline is the moat → decision pivots on whether off-the-shelf grounding reaches our live systems.

VP — Where are the cost levers in an AI feature?

Hit these points: cost scales with tokens sent → tighter selection + rerank cuts wasted context → compress long sessions; trim history → cache hot retrievals → right context on a cheaper model often beats wrong context on the flagship — a structural saving, not a discount.

VP — Where does investment in retrieval actually pay off?

Hit these points: retrieval fixes compound across every feature on the stack → a model upgrade is a flat tax on every call → better retrieval lifts accuracy, lowers cost, and reduces hallucination simultaneously → prioritize where wrong answers carry the highest business/compliance risk.

VP — How do we measure retrieval quality as a leadership metric?

Hit these points: recall@k and rerank precision on a labeled set → retrieval hit-rate in production → deflection/escalation for support, audit-pass for billing → track these separately from end-answer accuracy so we know whether to invest in retrieval or the model.

VP — What are the risk and compliance exposures?

Hit these points: PII in retrieved context → redaction + access control at the retrieve stage → prompt injection via poisoned/retrieved content (OWASP LLM Top 10) → guardrails before the model → auditability: log assembled context per call → for finance, deterministic retrieval + no-synthesis rule.

VP — When do we upgrade the model vs invest in retrieval?

Hit these points: instrument first: was the right context retrieved for the failing cases? → if no → fix retrieval (cheaper, compounds) → if yes and reasoning is the bottleneck (multi-step synthesis) → pay for model capability → never upgrade the model to paper over a retrieval gap.

7 · 5-minute revision guide (the spine)

  1. The model only sees its context window — a fixed token budget, not your data.

  2. Context is the new database query: retrieval decides what the model ever sees.

  3. Retrieve = recall first (lexical / semantic / hybrid), then rerank for precision.

  4. Chunk on meaning + overlap + per-chunk context; assemble within budget.

  5. Memory (per-user state) vs KB (shared corpus); compress long runs.

  6. Five failure modes: missing · wrong · outdated · conflicting · excessive.

  7. Review reflex: name the context strategy → name the failure → match retrieval to data type .

8 · 30-minute deep-dive revision (linking the track)

  1. Lesson 1 — What Is Context & Context-as-Query. Window as fixed budget; why bigger ≠ solved; the model is constant, context is variable; retrieval = the new SQL.

  2. Lesson 2 — Selection & Retrieval. Lexical vs semantic vs hybrid; recall vs precision; rerank; reciprocal rank fusion. Re-derive when each retrieval type wins.

  3. Lesson 3 — Chunking, RAG & Assembly. Split on meaning + overlap; contextual chunks; the RAG pipeline ingest→index→retrieve→assemble→LLM; assembly order and position bias.

  4. Lesson 4 — Memory, Compression & Failure Modes. Memory vs KB; compression for long-running agents; the five failure modes and their fixes; observability.

  5. Lesson 5 — Architecture Reviews & Production Design (here). Place real products on the pre-index↔read-on-demand spectrum; design billing/support/engineering/research agents by data type; run the review checklist.

  6. Self-test: for each lesson, state its one memory rule from memory, then design a small system that would violate it — and the fix.

9 · What to learn next

Next: Evaluation & Observability for LLM systems (“evals”) The natural sequel — this whole track kept saying “measure retrieval quality, not just answers.” Evals make that rigorous: labeled sets, recall@k, regression suites, LLM-as-judge, and tracing assembled context in production.

Sibling: Agent orchestration & multi-agent systems Once one agent’s context is solid, scale to many: planners, tool routing, sub-agent delegation, and how context flows (and compresses) between agents without losing provenance.

Retrieval practice — the capstone

Q1. Cursor's signature failure mode is best described as…

Q2. Claude Code's read-on-demand strategy trades freshness for what cost?

Q3. For a billing agent that must quote exact charges, the right retrieval is…

Q4. "Conflicting context" as a failure mode is fixed primarily by…

Q5. The reviewer's first move on any unfamiliar AI product should be to…

Sources
1. Anthropic, "Effective context engineering for AI agents" — anthropic.com/engineering. Context as a finite, curated resource; selection over dumping; the spine of every deliverable here.
2. Anthropic, "Building effective agents" — anthropic.com/engineering. Runtime, tool use, and when retrieval is warranted in production agents.
3. Anthropic, Claude Code documentation — docs.anthropic.com. Read-on-demand context model via tools; treated as version-dependent / at time of writing.
4. Cursor, documentation — cursor.com/docs. Codebase indexing via embeddings and semantic retrieval; product specifics are version-dependent / at time of writing.
5. Anthropic, "Introducing Contextual Retrieval" — anthropic.com/news/contextual-retrieval. Contextual embeddings + BM25 hybrid + rerank; covers the embedding blind spot.
6. Liu et al., 2023, "Lost in the Middle: How Language Models Use Long Contexts" — arXiv:2307.03172. Position bias behind the "excessive context" failure mode.
7. Lewis et al., 2020, "Retrieval-Augmented Generation for Knowledge-Intensive NLP Tasks" — arXiv:2005.11401. The RAG formulation behind the production pipeline.
8. OWASP, Top 10 for LLM Applications — owasp.org. Prompt injection via poisoned/retrieved context; basis for guardrails and the PII/compliance checklist item. Illustrative numbers throughout are at time of writing.
Was this lesson helpful? Thanks — noted.

These notes reflect my current understanding and are updated as I learn, build, and discover better explanations.