A research agent that cites its sources
For engineers
Build a research agent with a lead and workers that search in a loop, return quotes, pass a citation check and are measured by a calibrated judge.
A research agent you can trust splits the question across workers, makes every worker return a quote with each claim, checks every quote in code before anything is merged, and measures the whole system with a judge that has been compared with human labels. The model writing the answer is the least checked part of most research agents. This design checks the rest.
The situation
Tarn Analytics writes briefings for clients. A typical request: "How long may a health app keep user data in the EU, the UK and the US, and which regulators have acted on it since 2023?" An analyst used to spend two days on this. The team builds an agent that does the first pass, and an analyst reviews the result. The rule for the agent: no claim reaches the analyst without a source the system has checked.
Why this matters
A single chatbot call answers this question fluently and invents some of it. It may cite a real regulator page for something the page never says, or a paper that does not exist. Fluent text hides that. The analyst then has to check every line, and the agent saves no time.
How it is built
The design has four parts that match four skills.
- A lead agent decomposes the question. It writes a plan with one subtask per region and one for enforcement actions. Subtasks must not overlap, because workers run in parallel and cannot see each other. A worker count of three or four fits this question. A simple lookup would need one.
- Worker agents search in a loop. Each worker gets a brief: the objective, the output format, the allowed tools and sources, and a stop rule. It calls a search tool, reads the results, refines the query and stops when each part of its subtask has two supporting sources or its step budget runs out. This is agentic retrieval: the next search depends on what the last one returned.
- Every claim carries a checkable citation. A worker returns claims as structured items: the claim, the URL and the exact quote copied from the fetched page. A summary of the page is not enough, because the checker needs text to compare.
- A verifier checks before the lead merges. Code fetches each URL and confirms the quote appears on the page. A second model call then judges whether the quote supports the claim. A claim is supported, overstated, unsupported or contradicted. Only supported claims pass. The lead merges what passed, resolves conflicts between workers by going back to the sources, and leaves out anything no worker returned.
Then the team measures. An LLM judge grades each final claim pass or fail on one question: does the quote support the claim? Two analysts label 100 claims by hand, and the team compares the judge with them before trusting it.
Before and after
Before, the lead sends each worker the line "Research UK rules and report back." One worker returns a polished essay with three links. Another repeats the same search four times. The lead pastes both into one answer and adds a sentence from its own memory.
After, the brief says: find UK rules on retention of health-app data, return at most five claims as claim, URL and exact quote, use official sources first, and stop after eight searches or when five claims are supported. The lead refuses to add a claim that has no quote. The verifier rejects one claim that stretches a "common practice" into a legal rule, and the worker is asked to find a better source.
What goes wrong
- Overlapping subtasks. Two workers research the same law and report different numbers. The lead averages them. Neither number is checked.
- Looping and weak stops. A worker repeats a query, or stops at the first blog post. Cap the steps, reject repeated queries and require two sources.
- A link that exists but says something else. A page that loads proves nothing. Read the passage.
- A judge that was never calibrated. A judge that agrees with humans 84 times in 100 sounds good, but if it misses most of the unsupported claims, the dashboard looks green while the briefs are wrong.
- A floating judge model. If the judge model changes silently, scores move with no change in the agent. Pin the version and re-check it against the human labels when you change it.
Cost is real. Four workers read their own context and send output the lead must read, so total tokens rise roughly with the number of agents. Wall-clock time falls because the workers run at once. Spend that cost on questions where breadth and checked sources are worth it.
Steps
Split the question into non-overlapping subtasks
The lead agent plans before any search. One subtask per region and one for enforcement actions, each with its own scope so that two workers never research the same law. Pick the worker count from the number of independent parts, not from a wish for more coverage.
Lead agent plan Goal: How long may a health app keep user data in the EU, UK and US, and who has acted since 2023?
- Worker 1: EU rules and regulator decisions since 2023
- Worker 2: UK rules and regulator decisions since 2023
- Worker 3: US federal and state rules
- Lead: merge, resolve conflicts, write the briefing
Brief each worker with a format and a stop rule
A worker brief states the objective, the output format, the allowed tools and sources, and when to stop. Ask for structured claims, not an essay, so the next stages have something to check.
Worker brief - system
You are a research worker. Search with the web_search and fetch_page tools only. Prefer regulator and government sources.
- user
Find UK rules on retention of health-app user data. Return at most 5 claims as JSON: claim, url, exact_quote. Stop after 8 searches or when 5 claims have a quote from an official source.
- system
Let workers search, read and search again
Each worker calls the search tool, reads results and refines the query. Add the guards that stop failure: a step budget, a rule against repeating an identical query, and an evidence rule that requires two supporting sources before it stops.
Worker limits config/worker.yaml
max_steps: 12results_per_search: 5reject_repeat_queries: truestop_when: each_part_has_two_supported_sourcessources: official-firstRequire a quote and a link with every claim
Ask for the exact quote copied from the fetched page next to the URL. A quote is something code can find on the page. A summary of the page is only the worker's opinion of it.
One worker's returned claims - Claim: the regulator expects retention periods to be justified per purpose. URL: regulator guidance page. Quote: 'You must be able to justify how long you keep personal data for each purpose.'
- Claim: a 2023 EU decision cited delays in deleting data. URL: decision page. Quote: 'The controller did not erase the data within the period it had set.'
Verify each claim before merging
Code fetches the URL and confirms the quote is on the page. A second call compares the claim with the quote and labels it supported, overstated, unsupported or contradicted. Only supported claims reach the lead. Check dates for outdated or replaced sources too.
Verifier output Claim Quote found Label Action Retention justified per purpose Yes Supported Pass to lead UK law requires six years Yes Overstated Send back to worker Fine up to 4% of turnover No Unsupported Drop Merge, resolve conflicts and refuse unverified claims
The lead combines the verified claims, removes duplicates and goes back to the sources when two workers disagree. It adds nothing from its own memory. If a needed fact is missing, it sends a worker to fetch it with a quote.
Lead merge checklist Check
Every sentence in the briefing traces to a verified claim.
Conflicting figures are traced to their sources and explained, not averaged.
Claims no worker returned are removed.Calibrate a judge and watch the pass rate
Two analysts label 100 final claims as supported or unsupported. Run a pass or fail LLM judge on the same claims and compute how often it passes supported claims and how often it fails unsupported ones. Use it on larger samples only if the catch rate on unsupported claims is high enough. Pin the judge model version and re-check against the labels after any change.
Judge calibration Analyst label Claims Judge pass Judge fail Supported 70 66 4 Unsupported 30 12 18
Skills this scenario uses
Where to study
- How we built our multi-agent research system (Anthropic) (opens in a new tab)ArticleFree
Describes a lead agent that plans, runs parallel subagents and merges results, with lessons on briefs and cost.
- Building effective agents (Anthropic) (opens in a new tab)ArticleFree
Defines the orchestrator-workers pattern and when a simpler workflow is enough.
- Handoffs (OpenAI Agents SDK) (opens in a new tab)DocsFree
Shows how handoffs pass control, which is the contrast with calling an agent as a tool.
- Crossref Search (metadata and DOI lookup) (opens in a new tab)ToolFree
Look up a cited paper by title or DOI to see whether a real publisher record exists.
- Retraction Watch Database (opens in a new tab)ToolFree
Check whether a cited paper has been retracted.
- Creating a LLM-as-a-Judge That Drives Business Results (Hamel Husain) (opens in a new tab)ArticleFree
Walks through binary judges, labelling by a domain expert and checking agreement before use.
- Judging LLM-as-a-Judge with MT-Bench and Chatbot Arena (Zheng et al.) (opens in a new tab)PaperFree
The paper that measures position, verbosity and self-preference bias in LLM judges.