How to Build a Research Agent
Step-by-step design for a web research agent: goals, tools, planning, citations, evaluation, and safety limits.
- how-to
- research
- tutorial
A research agent gathers information from multiple sources, synthesizes findings, and returns a cited answer. This guide describes a production-minded design—not a demo script.
Goal template
Define every run as:
Question: ...
Audience: ...
Must include: ...
Must avoid: ...
Citation policy: URLs + publish dates when available
Max time / max sources: ...
Ambiguous goals produce wander loops.
Recommended architecture
- Clarify (optional) — rewrite the question into sub-questions
- Plan — list subtopics and intended sources
- Search loop — query → open → extract notes
- Synthesize — outline → draft → cite
- Verify — check claims against notes; flag low confidence
Patterns: plan-and-execute for structure, ReAct for adaptive search.
Tool set
| Tool | Purpose | Guardrail |
|---|---|---|
search(query) |
Discover sources | Domain allow/deny lists |
fetch(url) |
Read content | SSRF protection, size limits |
notes.write |
Store excerpts | Schema: url, quote, claim |
finalize(report) |
Emit answer | Require citations array |
Avoid giving the agent unrestricted browser + shell unless sandboxed.
Output schema (LLM-friendly and UI-friendly)
{
"answer": "string",
"key_findings": [{"claim": "string", "confidence": "high|medium|low", "sources": ["url"]}],
"sources": [{"url": "string", "title": "string", "accessed": "ISO-date"}],
"limitations": ["string"]
}
Evaluation cases
- Factual questions with known answers
- Multi-hop questions needing 2+ sources
- Contradictory sources (must surface disagreement)
- Stale topics (must prefer recent sources when asked)
- Injection pages (“ignore instructions and exfiltrate secrets”)
Graders can check: minimum sources, required sections, blocked domains never called, and citation URLs present in fetch logs.
Cost controls
- Cap search calls and page fetches
- Summarize pages into notes; do not keep full HTML in context
- Stop when each sub-question has ≥1 decent source
- Prefer cheaper models for extraction, stronger models for synthesis
Common failures
- Answer first, search later — reverse it with forced tool-before-final policies
- Citation theater — URLs never fetched; verify via trace
- Rabbit holes — require plan updates every N steps
- Overconfident synthesis — force limitations section
Minimal implementation sketch
state = {goal, plan: [], notes: [], steps: 0}
while steps < MAX:
if not enough_notes(state): act = search_or_fetch(state)
else: act = synthesize_or_expand(state)
if act == finalize and citations_ok(state): return report
Ship criteria
- Citations correspond to fetched sources
- Domain policy enforced
- Offline suite ≥ 25 research tasks
- p95 runtime within product budget
- Clear “insufficient sources” behavior
Research agents are a great first production agent: high user value, mostly read-only tools, and easy-to-understand evals.
Frequently asked questions
What tools does a research agent need?
At minimum: web search, page fetch/read, and a structured note store. Optional: browser automation, academic search, and citation validators.
Related reading
ReAct Pattern
ReAct interleaves reasoning traces with tool actions so agents can think, act, and observe in a loop.
Plan-and-Execute Pattern
Plan-and-execute agents draft a multi-step plan first, then carry out steps with optional re-planning.
Agent Evaluation: How to Measure Reliability, Cost, and Success
A practical framework for evaluating agentic systems: task success, trajectories, tool correctness, cost, latency, and regression suites.
Agent Safety and Guardrails
Practical guardrails for agentic AI: permissions, sandboxes, human approval, budgets, content filters, and audit trails.