Search⌘ K
AI Features

Benchmarking, Exam, and Interview Readiness

Evaluate a context-engineered on-call assistant against a naive prompt using fair benchmarks for token usage, cache hits, retrieval quality, and citation accuracy. Learn to validate results with a real model, choose meaningful metrics, answer the final exam, and defend design decisions in system design interviews.

We'll cover the following...

The on-call assistant is now built. It has a fixed prefix with tool masking, filtered hybrid retrieval with edge ordering and quote checks, a sandboxed runner, five workers over a shared state with verification, and a memory guarded by provenance, namespaces, versions, and expiry. That’s a lot more code than one prompt.

So any reviewer will ask the obvious question: is it actually better than putting everything into one big prompt? And if it is, by how much, and how do you know? In this lesson, we’ll write the project’s last file, evals.py, and run a fair side-by-side benchmark on the four numbers we named in Lesson 8.1. Then we’ll finish the course with a final exam and practice for system design interviews.

Build the naive baseline

A benchmark needs a control: the thing the project replaced. The naive version is what a team builds first. It puts every document and the team memory into one system prompt, sends all six tools, and asks the question. It has no retrieval filters, no stubs, and no rule about what goes before or after the cache breakpoint.

The engineered version is the project: the fixed 1,063-token prefix, with memory and filtered, edge-ordered retrieval after the breakpoint. It applies the Select move from Chapter 1 on every call.

To compare answers without a model, both arms use the fixed-rule drafter from Lesson 7.3, which quotes the two documents it trusts most. In the naive arm, those are the two best search matches, since a model reading the whole prompt would lean on them. In the engineered arm, they’re the two notes loaded in full at the edges.

Here’s how the two arms compare.

Both arms answer the same question from the same store; only the context they build differs
Both arms answer the same question from the same store; only the context they build differs

Here’s the evals file.

evals.py · Python 3.14.0
import re
from authority_filter import authority_filter
from context_prefix import build_request, prefix_of
from engine_config import SYSTEM_PROMPT
from eval_pipeline import draft_answer
from freshness_filter import freshness_filter
from hybrid_search import hybrid_search
from metrics import faithfulness
from note_metadata import NOTE_METADATA
from project_tools import PROJECT_TOOLS
from render_request import render_prefix
from retrieval import retrieve
FRESH, STALE = freshness_filter(list(NOTE_METADATA))
RETIRED = {doc_id for doc_id, _ in STALE + authority_filter(FRESH)[1]} # superseded or unapproved notes
def naive_arm(indexes, question, memory): # one big system prompt: every document plus memory
texts = {doc["doc_id"]: doc["text"] for doc in indexes["docs"]}
system = f"{SYSTEM_PROMPT}\n\nTeam memory:\n{memory}\n\nDocuments:\n" + "\n".join(f"[{d}] {t}" for d, t in texts.items())
ranked = [d for d, _ in hybrid_search(indexes, question, top_k=len(texts))["documents"]]
return {"prefix": render_prefix(PROJECT_TOOLS, system), "system": system, "rest": question, "context_ids": list(texts),
"answer": draft_answer(ranked, texts), "texts": texts} # the stand-in answers from the best matches
def engineered_arm(indexes, question, memory): # the project: fixed prefix, filtered retrieval after it
found = retrieve(indexes, question)
request = build_request({"question": question, "has_evidence": True},
f"Team memory:\n{memory}\n\n{found['context']}", [], summarize=None)
edges = [found["ordered"][0], found["ordered"][-1]] # the two notes loaded in full
return {"prefix": prefix_of(request), "system": request["messages"][0]["content"],
"rest": request["messages"][1]["content"], "context_ids": found["ordered"],
"answer": draft_answer(edges, found["texts"]), "texts": found["texts"]}
def citation_audit(answer, texts): # every claim found in its note, and no retired note cited
cited = set(re.findall(r"\[([\w.:-]+)\]", answer))
return faithfulness(answer, texts) == 1.0 and not cited & RETIRED

In the code above:

  • Lines 14–15: We find the retired notes, the ones the freshness and authority filters would drop: superseded runbooks and unapproved drafts. ...