---
title: "Local Deep Research: Open-Source Tools & a DIY Agent (2026)"
description: "Local deep research with Ollama or LM Studio: LangChain's Local Deep Researcher, LearningCircuit's Local Deep Research, and a 40-line DIY loop we tested with a 1B and a 31B model, plus how local your research really is."
category: "guides"
url: https://keirolabs.cloud/blog/local-deep-research
published: 2026-11-24
updated: 2026-11-24
---

# Local deep research: run a research agent on your own hardware (tested)

## The 60-second version

**Local deep research means running a research agent on your own hardware:** a local model through Ollama or LM Studio plans searches, reads results, finds gaps, searches again, and writes a cited report. Two open-source projects do this out of the box, or you can build the loop yourself in about 40 lines. We did, and tested it with a 1B and a 31B model. **Model size made the difference between a useful report and a confidently wrong one.**

| | LangChain Local Deep Researcher | Local Deep Research (LearningCircuit) | Build your own |
|---|---|---|---|
| **Models** | Ollama or LM Studio | Local and cloud (llama.cpp, Ollama, and more) | Anything |
| **Search** | DuckDuckGo by default; SearXNG and paid APIs optional | 10+ engines including arXiv, PubMed, SearXNG and your documents | Any search API |
| **Loop** | Query, search, summarize, reflect on gaps, repeat (3 loops by default) | Pipeline modes plus an agentic LangGraph mode | Yours to design |
| **Interface** | LangGraph Studio | Web app on port 5000 | Your code |
| **Install** | Clone, `.env`, `langgraph dev` | Docker, Docker Compose or `pip install local-deep-research` | `pip install` |

Details are from each project's README, checked November 2026.

## How does a local deep research agent work?

**The loop is the same in every implementation:**

1. **Plan:** turn the topic into a first search query.
2. **Search:** get results from a search engine.
3. **Summarize:** update running notes from the new sources, keeping citations.
4. **Reflect:** ask the model what's still unknown, and write the next query.
5. **Repeat** for a set number of cycles, then **write the report** with all sources.

LangChain's project describes exactly this: it generates a query, gathers results, summarizes them, "reflect[s] on the summary to examine knowledge gaps," and repeats "for a user-defined number of cycles."

## Option 1: LangChain's Local Deep Researcher

**A small, readable LangGraph app; the best starting point if you want to understand or modify the loop.**

```bash
git clone https://github.com/langchain-ai/local-deep-researcher.git
cd local-deep-researcher && cp .env.example .env
ollama pull deepseek-r1:8b      # or any model you prefer; set LOCAL_LLM in .env
```

Then start it with `langgraph dev` and open LangGraph Studio. Settings live in `.env`: `LLM_PROVIDER` (`ollama` or `lmstudio`), `LOCAL_LLM`, `SEARCH_API`, and `MAX_WEB_RESEARCH_LOOPS` (default 3). **The README notes that some small models struggle with the structured JSON output** the loop needs, and it falls back when they do.

## Option 2: Local Deep Research (LearningCircuit)

**A full research application:** a web UI, many search engines (including arXiv, PubMed and your own documents), a library you can download sources into and search later, and encrypted per-user databases. Its README reports **about 95% on SimpleQA with Qwen3.6-27B on a single RTX 3090,** using its agentic LangGraph mode. That's a self-reported result; the benchmark data is linked from the repository.

```bash
pip install local-deep-research
python -m local_deep_research.web.app      # web UI on http://localhost:5000
```

Docker and Docker Compose setups are in the README, including a GPU variant.

**Read its privacy notes before calling it "fully local".** The project itself points out that a self-hosted SearXNG "still forwards your search queries to its upstream engines on the internet," and that a local endpoint relaying to a hosted model (for example an Ollama cloud model) can send prompts off your machine.

## Option 3: build the loop yourself

**The whole loop in about 40 lines,** with the model through Ollama and search through an API:

```python
import json, os, requests
import ollama

MODEL = "llama3.2"       # swap in the largest model you've pulled (see our results below)

def llm(prompt: str) -> str:
    return ollama.chat(model=MODEL, messages=[{"role": "user", "content": prompt}]).message.content.strip()

def search(query: str, n: int = 5) -> list[dict]:
    r = requests.post("https://api.keirolabs.cloud/api/v2/search/lite",
                      headers={"Authorization": f"Bearer {os.environ['KEIRO_API_KEY']}"},
                      json={"query": query, "count": n}, timeout=30)
    r.raise_for_status()
    return r.json()["results"]

def deep_research(topic: str, cycles: int = 3, today: str = "2026-11-24") -> str:
    sources, notes = {}, ""
    query = llm(f"Today is {today}. Write one web search query (2-8 words) to start researching: {topic}\nReturn only the query.")
    for _ in range(cycles):
        for r in search(query.strip('"')):
            sources.setdefault(r["url"], r)          # dedupe across cycles
        listing = "\n".join(f"[{n+1}] {s['title']} ({u})\n{s.get('snippet', '')}" for n, (u, s) in enumerate(sources.items()))
        notes = llm(f"Topic: {topic}\nNotes so far:\n{notes or '(none)'}\n\nSources:\n{listing}\n\n"
                    "Update the notes with what the sources say. Keep facts with their [n] source numbers. Max 250 words.")
        gap = llm(f"Topic: {topic}\nNotes:\n{notes}\n\nWhat is the most important unanswered question? "
                  'Reply as JSON: {"done": true|false, "query": "next web search query, 2-8 words"}')
        try:
            step = json.loads(gap[gap.find("{"): gap.rfind("}") + 1])
        except ValueError:
            break                                    # small models sometimes skip the JSON; stop with what we have
        if step.get("done") or not step.get("query"):
            break
        query = step["query"]
    listing = "\n".join(f"[{n+1}] {s['title']} {u}" for n, (u, s) in enumerate(sources.items()))
    report = llm(f"Write a short research report on: {topic}\nUse only these notes and cite [n].\n\nNotes:\n{notes}")
    return report + "\n\nSources:\n" + listing

print(deep_research("What changed in PostgreSQL 18?"))
```

## What happened when we ran it

**We asked "What changed in PostgreSQL 18?" with two models.**

**Gemma 3 1B, running fully locally (an 815 MB model):** it stopped after one cycle and wrote a polished report that was mostly wrong. It claimed PostgreSQL 18 "introduced the `jsonb` data type" (jsonb has existed since PostgreSQL 9.4), invented a `parallel_query_optimizer` component, and left literal `[n]` placeholders instead of citations.

**Gemma 4 31B, the same code (run through Ollama's cloud for this test):** three cycles, with queries that followed the gaps ("new features and changes", then "release date and status", then "OAuth implementation details"). The report was accurate on the big items: the September 25, 2025 release, the new asynchronous I/O subsystem with `io_method` and `io_uring` on Linux, UUIDv7, `casefold()`, and OAuth authentication, all cited to sources. **One slip:** it listed `JSON_TABLE` as new in 18, but that shipped in PostgreSQL 17. The source it cited was a "Postgres 18" article that mentioned it.

**Lessons:**

- **Model size matters more than the loop.** Tiny models write fluent nonsense even with good sources in front of them. Use the largest model your hardware runs well; 20B to 30B-class models are where results got trustworthy in our test.
- **Citations need checking even with good models.** A cited source can be about the right topic and still not support the specific claim ([LLM citations](/blog/llm-citations)).
- **Snippets limit depth.** For detailed reports, read the top pages in full rather than summarizing snippets.

## How local is "local" deep research?

**The model can be local; the search can't.** Finding things on the web means sending queries somewhere: to DuckDuckGo, to the engines behind your SearXNG, or to a search API. The only fully local research is over your own documents. So:

- **Know where your queries go.** They reveal what you're researching.
- **Prefer a search provider with zero data retention** if queries are sensitive. On Keirolabs paid plans, add `"zdr": true` to the request body and nothing about the query is retained ([web search APIs with ZDR](/blog/web-search-api-zero-data-retention)).
- **Self-hosted SearXNG is private from the search API, not from the engines behind it,** and those engines rate-limit it ([SearXNG API not working?](/blog/searxng-api-alternatives)).

## Tips for better local research

- **Pass today's date** in every prompt; local models' sense of "now" is their training cutoff.
- **Raise the context window.** Ollama's default context is small for research notes plus sources.
- **Cap cycles at 3 to 5,** and stop early when the model says it's done.
- **Read full pages for the best sources:** Keirolabs `/search/content` returns results with page text in one call.
- **Want it done for you?** Keirolabs `/deep` runs multi-step research in one API call and scores 96.5% on SimpleQA ([deep search update](/blog/deep-search-update)).

Related: [Ollama web search](/blog/ollama-web-search), [Perplexica (now Vane)](/blog/perplexica-vane), [Claude deep research](/blog/claude-deep-research). New Keirolabs accounts get up to 2,000 free credits with no card ([get a key](https://platform.keirolabs.cloud/register)).
