βLearn to build reliable AI agent tools with Python. Implement request throttling, API retry handling, and domain-based source confidence scoring for an autonomous Deep Research Agent.β
Before an autonomous research agent can search the web, explore academic papers, and evaluate evidence, it needs a reliable set of tools.
In Part 5 of our Autonomous Deep Research Agent series, we begin building this tool layer. The focus is not just on making external requests: it is also about controlling how frequently those requests happen and introducing an initial mechanism for assessing source credibility.
We start by extending the project's Python dependencies.
The episode introduces these libraries:
HTTPX and aiohttp β for making HTTP requests.
arXiv β for accessing academic research papers.
PyPDF β for reading PDF documents.
Tenacity β for retrying operations that fail temporarily.
These libraries prepare the project for different research sources and document formats. Tenacity is particularly useful because external requests can fail due to temporary network problems or service limitations.
Retries should be bounded and configured carefully. Repeatedly retrying requests without limits can create unnecessary traffic and make rate-limiting problems worse.
An AI agent can execute tool calls much faster than a human. If a research workflow sends requests continuously, it may overload external services or trigger their rate limits.
To reduce this risk, we introduce a reusable asynchronous throttle function in the project's tools.py module.
The implementation tracks the last time each tool was called. Before a tool runs, it calculates how much time has elapsed since its previous call. If the required interval has not passed, the function waits before allowing the next request.
We use time.monotonic() to measure elapsed time. Unlike a wall-clock timestamp, a monotonic clock is designed for measuring time intervals without being affected by system clock adjustments.
Rather than hardcoding delays throughout the application, we make them configurable through environment variables.
The episode introduces:
A general minimum tool interval of 1 second.
A separate arXiv minimum interval of 5 seconds.
The separate interval reflects the need to be more conservative when interacting with services that have stricter access expectations.
These are project configuration choices, not universal limits. Always follow the policies and access rules of the services you use.
Finding a source does not automatically mean that its information is reliable.
We therefore introduce a simple domain-based confidence function. It extracts the hostname from a URL and compares it against predefined domain categories.
The episode groups domains into three categories:
High confidence: selected academic, scientific, government, and established publishing domains.
Medium confidence: selected general information and reference domains.
Default confidence: domains that do not match either predefined group.
The function assigns illustrative scores:
Category | Score |
|---|---|
High confidence | 0.90 |
Medium confidence | 0.75 |
Default | 0.55 |
These values are heuristic scores used by this project's initial implementation. They are not scientifically calibrated probabilities.
A domain alone cannot establish whether a particular page is accurate, whether its claims are supported, or whether the information is current. This score should therefore be treated as one signal among several, not as a final verdict on a source.
By the end of this episode, we have established two important building blocks:
A throttle mechanism to control how frequently tools are called.
A domain confidence function to provide an initial source-quality signal.
We also install the dependencies needed for web requests, academic research, PDF processing, and retry handling.
The episode begins the transition towards implementing the web-search tool, but the complete web-search and academic-search integrations are not finished here. Those are part of the continuing tool-development work.
With the initial tool infrastructure in place, the next step is to develop the research tools and connect them to the Researcher and Critic Agents.
As the project grows, these tools will support web research, academic-paper retrieval, evidence checking, and citation-related operations within the LangGraph workflow.
The larger goal is to build a research system that does more than retrieve information: it should also inspect, compare, and evaluate the evidence behind its findings.
YouTube series: Autonomous Deep Research Agent β Part 5
GitHub repository: https://github.com/snsupratim/research-agent
Project documentation: https://www.sndev.co/project/988de038-1e9a-4411-aac5-828477b52df8
Follow SN Dev for more practical tutorials on Agentic AI, LangGraph, Python, and AI Engineering.
Continue following "Deep Research Agent" with Building a Web Search Tool for AI Agents with Tavily API | Deep Research Agent Part 6.
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