Skip to content
mentoor

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.

  1. 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.
  2. 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.
  3. 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.
  4. 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

  1. Split the question into non-overlapping subtasks

    Skill: multi-orchestrator

    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?

    1. Worker 1: EU rules and regulator decisions since 2023
    2. Worker 2: UK rules and regulator decisions since 2023
    3. Worker 3: US federal and state rules
    4. Lead: merge, resolve conflicts, write the briefing
  2. Brief each worker with a format and a stop rule

    Skill: multi-orchestrator

    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
    1. system

      You are a research worker. Search with the web_search and fetch_page tools only. Prefer regulator and government sources.

    2. 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.

  3. Let workers search, read and search again

    Skill: rag-agentic

    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-first
  4. Require a quote and a link with every claim

    Skill: verify-citations

    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
    1. 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.'
    2. 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.'
  5. Verify each claim before merging

    Skill: verify-citations

    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
    ClaimQuote foundLabelAction
    Retention justified per purposeYesSupportedPass to lead
    UK law requires six yearsYesOverstatedSend back to worker
    Fine up to 4% of turnoverNoUnsupportedDrop
  6. Merge, resolve conflicts and refuse unverified claims

    Skill: multi-orchestrator

    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.

  7. Calibrate a judge and watch the pass rate

    Skill: evals-llm-judge

    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 labelClaimsJudge passJudge fail
    Supported70664
    Unsupported301218

Skills this scenario uses

Where to study