Ollama Research Agent is an advanced, fully local web research assistant designed to leverage any Large Language Model (LLM) hosted by Ollama. This tool facilitates comprehensive research by generating web search queries based on user-defined topics, gathering search results via Tavily, and summarizing the findings. It employs an iterative process to refine its understanding: after summarizing the initial results, it reflects on potential knowledge gaps, formulates new search queries to address these gaps, and conducts additional searches. This cycle repeats for a user-specified number of iterations, ensuring a thorough and well-rounded exploration of the topic.
The final output is a detailed markdown summary that includes all sources used during the research process. By integrating Open Source Large Language Models, Ollama Deep Researcher offers a powerful, customizable, and privacy-focused solution for in-depth web research. Its ability to autonomously refine queries and improve summaries makes it an invaluable tool for users seeking accurate and comprehensive information on complex subjects.
See it in action or build it yourself? Check out these helpful video tutorials:
- Overview of Ollama-Research-Agent with DeepSeek R1 - Load and test DeepSeek R1 distilled models.
- Building Ollama Research Agent from Scratch - Overview of how this is built.
ollama pull deepseek-r1:8b- Clone the repository:
git clone https://github.com/Sangwan70/Ollama-Research-Agent.git
cd Ollama-Research-Agent-
Get your web Search API from Tavily API
-
Copy the example environment file:
cp .env.example .env- Edit the
.envfile with your preferred text editor and add your API key:
# Required: Add search provider API key
TAVILY_API_KEY=tvly-xxxxx # Get your key at https://tavily.comNote: If you prefer using environment variables directly, you can set them in your shell:
export TAVILY_API_KEY=tvly-xxxxxAfter setting the key, verify they're available:
echo $TAVILY_API_KEY # Should show your API key- (Recommended) Create a virtual environment:
python -m venv .venv
source .venv/bin/activate- Launch the assistant with the LangGraph server:
# Install uv package manager
curl -LsSf https://astral.sh/uv/install.sh | sh
uvx --refresh --from "langgraph-cli[inmem]" --with-editable . langgraph devollama pull deepseek-r1:8b- Clone the repository:
git clone https://github.com/Sangwan70/Ollama-Research-Agent.git
cd Ollama-Research-Agent-
Get your web Search API from Tavily API
-
Copy the example environment file:
cp .env.example .envEdit the .env file with your preferred text editor and add your API keys:
# Required: Add search provider API key
TAVILY_API_KEY=tvly-xxxxx # Get your key at https://tavily.comNote: If you prefer using environment variables directly, you can set them in Windows (via System Properties or PowerShell):
export TAVILY_API_KEY=<your_tavily_api_key>Crucially, restart your terminal/IDE (or sometimes even your computer) after setting it for the change to take effect. After setting the keys, verify they're available:
echo $TAVILY_API_KEY # Should show your API key- (Recommended) Create a virtual environment: Install
Python 3.12(and add to PATH during installation). Restart your terminal to ensure Python is available, then create and activate a virtual environment:
python -m venv .venv
.venv\Scripts\Activate.ps1- Launch the assistant with the LangGraph server:
# Install dependencies
pip install -e .
pip install langgraph-cli[inmem]
# Start the LangGraph server
langgraph devWhen you launch LangGraph server, you should see the following output and Studio will open in your browser:
Ready!
Docs: http://127.0.0.1:2024/docs
LangGraph Studio Web UI: https://smith.langchain.com/studio/?baseUrl=http://127.0.0.1:2024
Open LangGraph Studio Web UI via the URL in the output above.
In the configuration tab:
- Verify your web search tool
Tavily - Set the name of your local LLM to use with Ollama (it will by default be
llama3.2) - You can set the depth of the research iterations (it will by default be
3)
Give the assistant a topic for research, and you can visualize its process!
Ollama Research Agent is inspired by IterDRAG. This approach will decompose a query into sub-queries, retrieve documents for each one, answer the sub-query, and then build on the answer by retrieving docs for the second sub-query. Here, we do similar:
- Given a user-provided topic, use a local LLM (via Ollama) to generate a web search query
- Uses a search engine (configured for Tavily) to find relevant sources
- Uses LLM to summarize the findings from web search related to the user-provided research topic
- Then, it uses the LLM to reflect on the summary, identifying knowledge gaps
- It generates a new search query to address the knowledge gaps
- The process repeats, with the summary being iteratively updated with new information from web search
- It will repeat down the research rabbit hole
- Runs for a configurable number of iterations (see
configurationtab)
The output of the graph is a markdown file containing the research summary, with citations to the sources used.
All sources gathered during research are saved to the graph state.
You can visualize them in the graph state, which is visible in LangGraph Studio:
The final summary is saved to the graph state as well:


