βBuild the Researcher Agent for our Autonomous Deep Research Agent, integrating web search, arXiv, source deduplication, confidence-based ranking, and automated citation generation.β
In this episode of our Autonomous Deep Research Agent series, we move from building individual research tools to integrating them into the Researcher Agent β the component responsible for gathering, organizing, ranking, and preparing sources for the research pipeline.
The Researcher Agent receives the original user query, the maximum number of sources, and the subqueries generated by the Planner Agent. It then systematically searches for relevant information using web search and academic research.
Instead of collecting unlimited results, we implement source limits, duplicate URL filtering, and confidence-based ranking to keep the research process structured and efficient.
The Planner Agent generates subqueries from the user's original research question. These subqueries become the foundation of the Researcher Agent's workflow.
The Researcher receives the shared AgentState, extracts the query, subqueries, and source limit, and begins collecting research material.
This creates a separation of responsibilities:
Planner Agent: Breaks the research question into smaller subqueries.
Researcher Agent: Executes those subqueries, gathers sources, and prepares research evidence.
The Researcher iterates through planner-generated subqueries and uses web search to collect relevant information. For the first three subqueries, it also performs academic research using arXiv.
Collected sources are checked against previously seen URLs to prevent duplicates. Once the research collection is complete, the sources are ranked using their domain-based confidence score, limited to the maximum number requested, and passed through the citation builder.
Generating Architecture Diagramβ¦
The Researcher Agent integrates two search capabilities:
Tavily is used to retrieve relevant web sources for every generated subquery. The number of results is controlled by distributing the maximum source limit across the total number of subqueries.
This prevents a single subquery from consuming the entire research source budget.
For the first three subqueries, the Researcher also searches arXiv to retrieve academic papers relevant to the research topic.
This introduces academic literature into the research pipeline alongside web-based information, helping the agent collect different types of sources.
During research, the same website or paper may appear across multiple search queries.
To avoid collecting duplicate material, we maintain a set of previously seen URLs. Whenever a new source is retrieved, its URL is checked against this set.
If the URL is new, it is added to the collection.
If the URL already exists, the source is skipped.
This ensures that the final research collection contains unique source URLs rather than repeated search results.
Not every source collected during research has the same level of reliability.
Once the research process finishes gathering sources, the agent sorts them using the existing domain-based confidence score. Sources with higher scores are prioritized, while lower-confidence sources are placed further down the list.
The Researcher then applies the maximum source limit configured by the user, retaining the highest-ranked sources within that limit.
This is a heuristic ranking mechanism based on domain confidence, not a complete factual verification system.
After the sources have been collected, deduplicated, ranked, and filtered, the Researcher passes them to the citation builder.
The citation tool generates structured citation information and numbered references for the research material. These citations are then included in the state returned by the Researcher Agent.
This gives downstream agents a structured collection of sources that they can use when processing and generating the research report.
The Researcher Agent now connects several previously implemented tools into a single research workflow:
Planner-generated subqueries
Tavily web search
arXiv academic paper search
Unique URL tracking
Source limit management
Domain-based confidence ranking
Citation generation
Research progress logging
Instead of treating search tools as isolated functions, we now have an agent node that orchestrates them to gather and prepare research material.
With the Planner Agent generating research queries and the Researcher Agent collecting and organizing evidence, the next step is to introduce another critical component of the pipeline: the Critic Agent.
The Critic will help evaluate the research gathered so far and take our Autonomous Deep Research Agent one step closer to a more structured, quality-aware research workflow.
GitHub Repository: https://github.com/snsupratim/research-agent
Project Documentation: https://www.sndev.co/project/988de038-1e9a-4411-aac5-828477b52df8
This project is part of the Autonomous Deep Research Agent series on SN Dev, where we build real-world AI Engineering projects using Python, FastAPI, LangGraph, and Gemini.
Continue following "Deep Research Agent" with Building the Critic Agent: Detecting Conflicting Research | Deep Research System Part 9.
Ask questions, discuss architecture, and share insights with other developers.
Sign in to join the discussion and share your thoughts with other developers.
Sign In to Comment