AI Interviews · Question

Design a multi-agent system that produces a research report with citations.

ML / LLM system design question reported at PromptLayer (Jul 2025). Sources, confidence and an answer card.

Researched · updated

eng-024 AI Engineer Agent design & reliability ML / LLM system design Medium confidence
On this page

What they’re really asking

If you only remember one thing, say this in the first minute: “A lead model turns the question into four to six sub-questions. Read-only workers research them in parallel, and every finding they return carries the source and the exact quoted passage. Code checks each quote really appears in the fetched page and drops the ones that don’t. One writer drafts the report only from checked findings, and a final check makes sure every factual sentence has a citation that supports it. Several agents pay off here because the reading is parallel, and only one of them writes.”

The rest of this page explains each part of that answer.

PromptLayer’s own post on this whiteboard exercise lists what it looks for: “Clear problem decomposition into sub-tasks”, “Logical flow between agent steps”, “Consideration of error handling and edge cases” and “How they’d structure prompts for each component”. It tells interviewers “Don’t go too in the weeds” (PromptLayerfirst-hand · Jul 2025). So the interviewer wants a clear pipeline, a prompt per step, citations you can trust, and a reason for using several agents.

What makes this different from a normal pipeline

A normal data pipeline fetches documents, transforms them and writes output. Every step is code, so you can trust what comes out if the code is right.

Here the summarizing and writing are done by a large language model (LLM). A model can be confidently wrong. It can write a sentence that sounds sourced and isn’t, or invent a quote. This is called hallucination. In a research report, the most damaging form is a made-up citation, because it looks like proof.

There is also a cost question. An agent is a loop in which the model chooses its own next action (search, open a page, take notes) until it is done. A multi-agent design runs several of these loops, often a lead that plans and workers that each do a part. That buys parallel reading, at the price of many more tokens.

Clarify first

  • Sources? The open web, internal documents, or both? Assume the web plus an internal wiki.
  • Report length and deadline? Assume 3–5 pages within 10 minutes, asynchronous.
  • What counts as a valid citation? A URL, or a quoted passage? Assume a quoted span from a fetched page.
  • Budget per report? Assume a few dollars at most.

Say it like this: “I’ll treat a citation as valid only if it quotes a passage we actually fetched. That gives me something I can check in code.”

Answer

Words you need first

  • Token: the unit models read and write, roughly ¾ of a word. Providers bill per token.
  • Structured output: the model must answer in a fixed JSON shape, so code can check it.
  • LLM judge: a second model call that grades an output against a question (“does this passage support this sentence?”). It is cheaper than a person but can also be wrong, so you check it against people on a sample.

The pipeline (orchestrator-workers)

User question
   │
   ▼
1. Plan (lead model) ── outline of 4–6 sub-questions
   │
   ├──► Worker A ─┐
   ├──► Worker B ─┤   2. Research, in parallel, read-only:
   ├──► Worker C ─┤      search, fetch, extract
   └──► Worker D ─┘      each finding = {claim, source_url, quoted_span}
   │
   ▼
3. Code: dedupe sources; is each quoted_span really in the fetched page?  no → drop
   │
   ▼
4. Write (strong model) ── each section only from checked findings, citing their ids
   │
   ▼
5. Check citations ── code: every factual sentence has an id
                      judge: does the cited span support the sentence?
   │
   ▼
Report
  1. Plan (lead model). Turn the question into an outline of 4–6 sub-questions.
  2. Research (parallel workers, read-only). Each worker searches, fetches and extracts findings for one sub-question. Every finding is {claim, source_url, quoted_span}. Workers return short findings, not their whole browsing history.
  3. Deduplicate and check (code). Drop duplicate sources. Verify each quoted span appears in the fetched page. Findings that fail are dropped, not repaired.
  4. Write (strong model). Draft each section only from checked findings, citing their ids.
  5. Check citations (code plus a judge). Every sentence with a factual claim has a citation id. An LLM judge checks that the cited span supports the sentence, on a sample or on all of them if the budget allows.

Prompts: one short system prompt per role, each with an output schema: planner, researcher, writer, judge.

Say it like this: “Code checks that the quote exists. The judge checks that the quote supports the sentence. Those are two different failures.”

Follow one report

Question: “How are mid-size SaaS companies handling EU data-residency requirements?” (an illustrative example).

StepWhat happensWhat to say in the interview
Plan5 sub-questions: the rules, cloud-region options, contracts, costs, internal wiki notes.”Decompose first; the interviewer is grading this.”
Research5 workers run in parallel and return 38 findings with quotes.”Reading is parallel, so several agents pay off.”
Check4 quotes aren’t in the fetched pages; dropped. 2 duplicate sources merged.”Made-up quotes die here, in code.”
WriteOne writer drafts 4 pages from 32 findings.”One writer, so tone and facts stay consistent.”
JudgeOne sentence cites a span that doesn’t support it; it is cut.”The judge catches a real quote used for the wrong claim.”
GapThe cost worker timed out; the report says that section is thin.”Report gaps, don’t fill them.”

Is multi-agent worth it here?

Research is the case where it pays: sub-questions are independent and reading happens in parallel. Anthropic reports its lead-plus-subagents system “outperformed single-agent Claude Opus 4 by 90.2%” on an internal research evaluation, but that multi-agent systems “use about 15× more tokens than chats” (2025-06-13). Only the writer writes, so the conflict problem (two agents editing the same text) doesn’t arise.

Error handling

Each worker has a timeout. A worker that fails leaves a gap that the writer reports rather than fills. Blocked or paywalled pages are skipped. Each report has a total token and dollar cap.

What it costs

Assume 5 workers at about $0.20 each, plus about $0.20 for planning and writing. One report then costs about $1.20 before prompt caching (a provider discount for re-reading the start of a prompt it has seen recently). That fits the “a few dollars at most” budget.

The arithmetic behind the numbers
  • Cost ≈ W × worker run cost + planner + writer + citation checks, where W = parallel workers (sub-questions).
  • A worker is an assumed 8-step loop at Claude Sonnet 5 list price (fetched 2026-10-11): about $0.20, because an agent re-sends its growing history at every step.
  • 5 × $0.20 + about $0.20 ≈ $1.20 per report, before caching.

Senior vs Staff

Research report

Senior

  • Lays out plan, parallel read-only research, verified citations and one writer, with per-step prompts and caps.

Staff

  • Justifies multi-agent with parallelism and a token budget, measures citation validity and answer quality on a set of real questions, and says when a single agent would do.

In plain words: a Senior answer builds a pipeline whose citations can be trusted. A Staff answer also defends why several agents are worth their token bill here, and says when one would be enough.

Small-team version

Most small teams build this as a single agent loop that makes several tool calls at once, not as separate agents. It gets the same parallel reading with fewer moving parts.

Build the citation check yourself. It is a few lines of code and catches made-up quotes. Start with 20 real questions from users as the eval set: a fixed list you re-run before every prompt or model change. Use a hosted search API rather than building a crawler.

Pitfalls

  • Citations as URLs with no checked passage. A URL proves nothing; the page may not say what the sentence claims.
  • Workers that each write a section. The report ends up with uneven tone and repeated facts, and you have created a multi-writer problem for no reason.
  • No per-report budget. A worker that keeps searching can run up the bill on a single question.
  • Going deep on one component when the interviewer wants the flow. PromptLayer tells its interviewers not to “go too in the weeds”, so neither should you.

Go deeper

Family

Agent or workflow? Designing multi-step LLM automation

Automate an internal process with LLMs: put each step in plain code, one model call or a capped agent loop, check what the model produces, run it so it survives restarts, and add more agents only when it pays.

Other questions in this family