Drills D05

Deep-research agent with citations

Design an agent that takes a research question, searches the web for several minutes, and returns a report where every factual claim is cited. How do you make the citations trustworthy, and how do you keep cost under control?

45 minutes · revise 18.06 · 18.07 · 25.02 · 25.04 · 17.09 · 20.07 · 31.12

This prompt tests whether you can bound an open-ended agent. Search can go on forever, pages contain instructions aimed at your model, and a fluent report with plausible links is easy to produce and hard to trust. The interviewer wants a budgeted plan-search-read-write loop, an evidence store that separates reading from writing, citations verified by code, and an honest answer to “one agent or many?”.

Clarify and scope

Baseline architecture

 question ─► clarify (optional 1-2 questions) ─► lead planner
   plan = sub-questions + search intents + budget per sub-question
   ─► fan out: N workers in parallel, each with its own context
        loop (max S steps): search ─► pick results ─► fetch page
              ─► clean (strip nav, scripts, hidden text) ─► snapshot (url, hash, fetched_at)
              ─► extract notes {claim, quote, url, published_date, snapshot_id}
        return compact notes, never raw pages
   ─► evidence store (dedupe by url + quote, near-duplicate pages merged)
   ─► lead reviews coverage: gaps? conflicts? ─► at most one more round
   ─► writer: outline ─► sections, each sentence cites note ids only
   ─► verifier (code + small model):
        cited note exists? quote found in snapshot? quote supports sentence?
        numbers and dates in sentence present in quote?
   ─► report + sources + "conflicting evidence" + "could not verify"
 budget guard on every step: searches, fetches, tokens, wall time, money

The single most important line is “the writer cites note ids only”. The writer never sees a raw page, so it cannot cite something that was never extracted, and every citation resolves to a stored snapshot. That makes verification a lookup instead of a judgement. The advanced RAG chapter covers the iterative search pattern.

Key choices and trade-offs

One agent with parallel searches, or orchestrator and sub-agents? Sub-agents give context isolation: each worker reads dozens of pages and hands back a few hundred tokens of notes, so the lead’s context stays small and focused. Anthropic’s June 2025 engineering post on its own research system reports that a lead agent with sub-agents beat a single agent by 90.2% on its internal research eval, used about 15 times the tokens of a chat, and suits breadth-first questions rather than tasks where every agent needs the same context. Those are the vendor’s own numbers on its own eval. The cost: more tokens, more latency, and coordination failures (two workers researching the same thing, a worker drifting off scope). For narrow questions a single agent issuing parallel searches is faster and cheaper. Route by question breadth: the planner decides how many workers to start, from zero to a cap.

Search quality. Ask the planner for neutral queries (no leading wording, no assumed answer), use site: queries for primary sources, and keep a domain deny list for content farms. Prefer the newest authoritative source and record the publish date on every note.

Fetch and snapshot. Search snippets are too short to support most claims; fetch the page, clean it and store a snapshot with a hash. Citations point at the snapshot, so they stay checkable when the live page changes.

Budgets as first-class design. Per report: maximum workers, steps per worker, searches, fetches, tokens and wall time, plus a money ceiling computed from token counts as you go. When a budget runs out, the system writes with what it has and lists the open sub-questions. See agent budgets.

Model mix. A strong model for planning and writing; a cheap fast model for workers’ page reading and note extraction, where most tokens go; a small model or code for verification.

Evals

Guardrails and fallbacks

Observability and cost

A trace tree per report: lead span, one span per worker, a span per search and fetch with URL and status, extraction token counts, verifier verdicts. Dashboards: cost per report (p50, p95), wall time, budget-hit rate, citation precision from sampled judge runs, verifier drop rate, top fetched domains. Alert when p95 cost per report creeps up; it is the first sign of a looping worker.

The numbers

Per report (assumptions to state).

sub-questions             6
searches                  6 × 3          = 18
pages fetched             6 × 5          = 30
tokens per cleaned page   ~6K            → 180K tokens read by workers
worker overhead           ~20K in, notes 30 × 400 = 12K out
lead planning + review    ~2 × 10K in, ~3K out
writer                    ~20K in (notes + outline), ~4K out
verifier                  ~60 claims × ~300 tokens = ~20K in, ~2K out

So roughly 220K input and 14K output tokens on the cheap model (workers and verifier), and about 40K input and 7K output on the strong model.

Cost per 1K reports (P in dollars per million tokens, check current prices):

cheap  = 220 × P_in_small + 14 × P_out_small
strong = 40 × P_in_large + 7 × P_out_large
search = 18,000 × P_search            (per-search fee, if billed)
total  = cheap + strong + search + fetch/proxy infrastructure

Page reading dominates token volume, which is why it goes to the cheap model and why cleaning pages (dropping navigation and boilerplate) is a cost lever, not just a quality one.

Latency. Planning 10 to 20 s. Workers in parallel, each about 5 steps of search (1 to 3 s), fetch (1 to 5 s) and extraction (3 to 10 s): about 1 to 3 minutes. Optional second round: another 1 to 2 minutes. Writing 30 to 60 s, verification 20 to 40 s. Total about 3 to 6 minutes.

Throughput. 2,000 reports a day × 30 fetches = 60K fetches a day, under 1 per second averaged; peaks maybe 5×. Fetching is not the bottleneck; provider token rate limits on the cheap model might be, at about 2,000 × 220K = 440M input tokens a day.

Follow-ups they will ask

How to bring in your own work

Memory Agent is a small research agent, so this is one of your strongest drills. Be clear it is a chat agent with one search tool, not a multi-minute report writer.

esc

Narrow with repo:jm layer:eval q:naive mine · ↑↓ to move, enter to open