Research agent that cites its sources
A research agent with citations answers a question in a few paragraphs, and every claim carries a marker such as [2] that points at the passage it came from. The design that works is to fix the set of sources first, let a supervisor agent plan and delegate checks to worker agents, then resolve every marker against the sources and fail the run when a claim cites a source that does not exist or does not support it. L2M gives you the parts: a knowledge base with hybrid retrieval, the Supervisor node, Extract Citations, and a grounding check.
The job
| Input | A research question ("What changed in our incident process this year, and why?") |
| Sources | Documents you chose: reports, papers, notes, web pages you saved, in a knowledge base |
| Output | A short brief whose claims end in [N] markers, each resolved to a chunk id and source id |
| Never | A citation to a source that was not retrieved, or a claim its cited source does not support |
Made-up and mismatched citations are a measured problem, not a rare one. The ALCE benchmark by Gao et al. scores cited answers along "fluency, correctness, and citation quality", and reports that "on the ELI5 dataset, even the best models lack complete citation support 50% of the time". A research agent therefore needs a citation check built into the run, not just a prompt that asks for citations.
Why a supervisor here, and when not. A single retrieve-then-answer workflow handles "what does our policy say about X". Research questions are wider: they have parts (what changed, when, why, what it costs), some parts need arithmetic, and a draft benefits from a second pass that checks claims against the sources. A supervisorSupervisor agent: An agent whose tools include other agents: it splits a task, hands each part to a worker agent, and combines the answers into one reply. that delegates those parts to narrow workersWorker agent: A specialist agent, with its own model, tools and instructions, that a supervisor agent calls like a tool for one part of a task. fits that shape. It also costs more model calls and is harder to test. If your questions are narrow, use the internal docs Q&A design instead; supervisor and workers explains the pattern in depth.
The design
1. Fix the sources before the agent writes
Put the material in a knowledge base first: upload the reports and notes, and for web pages, save the text of the pages you decided to trust and upload it with the page's URL as the sourceId. Then one RAG Retrieve step with searchMode: "hybrid" and a topK of 6 to 10 gives the supervisor a numbered list of passages, and the same list feeds Extract Citations.
Why not let workers browse the open web and cite URLs? You can attach read-only fetch or search tools, but Extract Citations resolves [N] markers against a list of retrieved documents, normally a RAG Retrieve or Rerank step's output, and the Output Guardrail's grounding check compares the answer only with the documents of the Retrieve or Rerank steps upstream, not with what a tool fetched. A URL a worker quotes from a fetched page is then just text in the answer: nothing in the run checks that the page says what the claim says. Keeping "gather" and "answer" apart also gives a person the chance to drop a bad source before anything cites it.
2. The supervisor and its workers
- Supervisor (
supervisor_node): its user prompt holds the citation instructions, the numbered passages and the question. Its system prompt says: plan the parts, delegate checks and arithmetic, then write the brief and cite only the numbered passages. Give it amaxIterationsabove the workers' (the node's sample config uses 10). - checker (
agent_orchestrator, no tools): given one draft claim and the passage it cites, it says whether the passage supports it. The supervisor must put both into thetask_prompt, because a worker does not see the supervisor's conversation. - analyst (
agent_orchestrator, a calculator MCP tool): does the arithmetic, so the brief does not carry a number the model estimated.
One wiring detail matters. Connect the question to the retrieve step only, not straight to the supervisor, and write the supervisor's prompt with the retrieve step's query field. A worker is built from the supervisor's inputs, and a user_prompt that an upstream step outputs (a Text Input does) overrides the task the supervisor wrote. On our test install, when the question node was also wired to the supervisor, the checker worker received the original question as its user prompt instead of its task. With the question reaching the supervisor only through the retrieve step, the worker received the task: "Check this draft claim against source [1]: the reset link is valid for 30 minutes."
Every tool here only reads. If you add tools from a server that also has write tools, turn on the workflow's No write tools setting, which blocks every tool the MCP tool policy counts as a write tool. A research agent needs an approval only when it publishes something: put an Approval Gate on the step that posts the brief to a channel or a wiki, so a person reads it first (approval gates).
3. Resolve and check every citation
Extract Citations reads the supervisor's answer and the retrieve step's documents and returns each marker with its chunkId, sourceId and the cited text. Then an Output Guardrail with checks: ["grounding"] and onFail: "error" checks each claim against the passage it cites (grounding in sources).
We ran this design on a local install with a scripted stand-in model, so the answers were fixed text, not a real model's. The knowledge base held three passages: password reset, billing, and an error code. The results:
| Supervisor's final answer | Extract Citations | Grounding check |
|---|---|---|
Correct claims citing [1] and [2] | 3 citations, 2 documents | Passed |
A correct claim citing [3], the billing passage, instead of [2] | 3 citations | Failed the run |
A claim citing [7], with three passages | Only the [1] resolved; [7] silently skipped; hasCitations: true | Failed the run |
"The reset link is valid for 24 hours and arrives by text message" citing [2], the error-code passage | 1 citation | Failed the run |
The third row is the lesson: hasCitations alone does not catch an invented source, because one real marker is enough to make it true. The groundingGrounding: Keeping a model's answer to what the documents it was given actually support, so each claim can be traced back to a source. check does. It compares words, so it misses a claim that changes one figure in an otherwise matching sentence and can flag a fair paraphrase; turn on grounding.requireCitations when every sentence must carry a marker.
How to test it
Research answers vary in wording, so test what must not vary: which sources are cited, that every marker resolves, and that the run passes the grounding check. An evalEval: A test for an AI system: give it an input, run it, and apply grading logic to the result to decide whether it succeeded. built on a golden set does that (golden sets, AI agent evals):
| Case | Input | A pass |
|---|---|---|
| Single-source fact | A question one passage answers | Cites that passage; run status success |
| Two-part question | A question whose parts sit in two documents | Cites both; the trace shows the right workers called |
| Arithmetic | "How many uncached lookups a day at 1,250 queries and an 18% miss rate?" | 225, with the delegation to the analyst in the trace |
| Not in the sources | A question no passage answers | Says the sources do not cover it; no marker |
| Planted conflict | Two passages that disagree on a date | Cites both and names the conflict |
Score with status (a grounding failure fails the run, so a case that starts inventing sources fails here), regex or contains for required source ids, and an llm_judge rubric for the brief's quality (see LLM as judge for its biases and how to calibrate it). faithfulness asks a judge model whether each claim is supported by the retrieved passages. A replay of a recorded run answers the retrieval and the MCP calls from the recording and reruns the models, so it isolates a prompt or model change (regression testing agents).
What it costs to run
Count model calls. In our run the supervisor made two calls (one delegation, one final answer) and the checker one: three in all. Each delegation adds at least one worker call, and each round of delegation adds a supervisor call. Tokens grow faster than calls: the numbered passages sit in the supervisor's prompt and are sent again on every supervisor iteration, and each worker's full output, including its steps, comes back into the supervisor's context. Keep topK modest, cap each agent's maxIterations, lower toolMessageMaxChars on the supervisor if worker outputs are long, and set a budget so a confused supervisor that keeps delegating cannot run up spend.
Starting point, honestly
Two recipes cover the parts; you combine them.
- Supervisor and worker agents (
supervisor-worker-swarm-flow.json): a supervisor with a researcher worker (a mock knowledge-base tool) and a computer worker (calculator and clock), on the echo model and the bundled mock MCP server. Echo never asks for a tool, so as shipped the supervisor answers on its first turn and delegates nothing. It has no retrieval step and no citations. - RAG with citations (
rag-with-citations-flow.json): retrieve, citation prompt, LLM, Extract Citations. No agents.
To build the design above: start from the citations sample, replace its prompt and LLM with a Supervisor whose user prompt holds the passages and the citation instructions, attach the workers and their chat models, wire the retrieve step into Extract Citations, add the Output Guardrail, and use a real chat model on each agent. The recipes have the import steps.
The live demo's research team shows delegation: a supervisor sends a lookup to a researcher with a knowledge-base tool and a sum to an analyst with a calculator, then writes a summary. Its recorded run uses a scripted stand-in model, and it has no citation step.
Related jobs: the security questionnaire agent uses the same citation check one question at a time, and an incident triage agent uses a supervisor to gather evidence.
Further reading
- Enabling Large Language Models to Generate Text with Citations (arxiv.org): Gao et al., 2023, the ALCE benchmark
- Retrieval-Augmented Generation for Knowledge-Intensive NLP Tasks (arxiv.org): Lewis et al., 2020
- Multi-agent systems: supervisor and worker agents
- Knowledge bases: citations
- Output checks: grounding in sources