Skip to content

Latest commit

Β 

History

11 Commits

Folders and files

NameName
Last commit message
Last commit date
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

πŸ”¬ Deep Research

An open-source, multi-agent AI research system that thinks, searches, and writes like a senior analyst.

Built on LangGraph and inspired by langchain-ai/open_deep_research, this project takes a research question and autonomously decomposes it, delegates to parallel sub-agents, synthesizes web-sourced findings, and produces a structured, cited report all without you lifting a finger mid-process.


Why This Exists

Most AI research tools are wrappers around a single LLM call with a search API bolted on. That works for shallow queries. It breaks down fast when you need something with actual depth comparisons, multi-angle investigations, conflicting sources, nuanced synthesis.

Deep Research approaches this differently: it mimics how a small research team operates. A supervisor agent reads your question, decides how to break it down, and spawns specialized sub-agents that work in parallel on independent sub-topics. Each agent searches, reflects, and compresses its findings. The supervisor aggregates everything and a final writer model produces the report.

The result is meaningfully better than a single-shot search-and-summarize approach especially for complex, multi-faceted questions.


Architecture

User Query
    β”‚
    β–Ό
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚   Clarification     β”‚  ← Asks one focused follow-up if needed
β”‚   + Brief Writing   β”‚  ← Transforms conversation into a research brief
β””β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
         β”‚
         β–Ό
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚                   Supervisor Agent                          β”‚
β”‚                                                             β”‚
β”‚   think_tool β†’ ConductResearch (parallel) β†’ assess gaps    β”‚
β”‚                      β”‚         β”‚                           β”‚
β”‚              β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”˜         └────────┐                 β”‚
β”‚              β–Ό                          β–Ό                  β”‚
β”‚      Sub-Agent 1                Sub-Agent 2  (up to N)     β”‚
β”‚   [search β†’ reflect β†’ search]   [search β†’ reflect β†’ ...]   β”‚
β”‚        └── compress β”€β”€β”˜              └── compress β”€β”€β”˜      β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                       β”‚
                       β–Ό
              Final Report Writer
         (cited, structured markdown)

Each sub-agent runs in an isolated context window no cross-contamination of research threads. The supervisor sees only compressed summaries, keeping token usage reasonable even for broad queries.


Features

  • Parallel research execution multiple sub-agents run concurrently via asyncio.gather, cutting wall-clock time significantly for multi-part questions
  • Supervisor-researcher pattern clean separation between strategic coordination and execution
  • Structured scoping clarification + brief-writing phase ensures the agents research the right thing
  • Think-tool reflection agents pause and self-assess after each search, reducing useless extra calls
  • Research compression each sub-agent's output is compressed before returning to the supervisor, keeping context windows manageable
  • MCP integration optional Model Context Protocol support for local file-based research (swap web search for your own document corpus)
  • Swappable models each component (supervisor, researcher, compressor, writer) uses independently configurable models; mix providers freely
  • Inline citations all source URLs are tracked and included in the final report

Stack

Layer Choice
Orchestration LangGraph
LLM abstraction LangChain
Search Tavily
Default models Google Gemini (flash-lite variants)
MCP integration langchain-mcp-adapters
Data validation Pydantic v2

Getting Started

Prerequisites

  • Python 3.12+
  • API keys for your chosen LLM provider(s) and Tavily

Installation

git clone https://github.com/rudraksh-jani/deep-research
cd deep-research
pip install -e .

Or with uv:

uv sync

Environment Setup

# Required
export TAVILY_API_KEY="your-tavily-key"

# Pick your LLM provider(s)
export GOOGLE_API_KEY="your-google-key"         # for Gemini models
export ANTHROPIC_API_KEY="your-anthropic-key"   # for Claude models
export OPENAI_API_KEY="your-openai-key"         # for GPT models

Run It

from langchain_core.messages import HumanMessage
from deep_research.research_agent_full import agent
import asyncio

result = asyncio.run(agent.ainvoke({
    "messages": [HumanMessage(content="Compare transformer and mamba architectures for long-context tasks")]
}))

print(result["final_report"])

How the Agents Think

Supervisor

The supervisor receives a research brief and must decide:

  1. Can a single sub-agent handle this, or does it need parallel decomposition?
  2. After results come back, is there enough to write a good report, or should it dig deeper?

It uses think_tool before and after each ConductResearch call to reason explicitly about these questions the reflection is part of the state, not just vibes.

Sub-agents (Researchers)

Each sub-agent is a tight loop: llm_call β†’ tool_node β†’ llm_call β†’ .... The loop runs until either the model stops calling tools (it's satisfied) or the iteration budget is hit. After exiting the loop, a compression step runs to extract the substance and drop the scaffolding before returning to supervisor.

Hard limits on tool calls are baked in per agent to prevent runaway costs on weird edge cases.

MCP Mode

Swap out Tavily for local files. Useful when your research corpus is internal docs, PDFs, or any document set you've already collected. The MCP filesystem server runs as a subprocess; the agent calls list_directory, read_file, search_files etc. instead of web search. Everything else stays identical.

from deep_research.research_agent_mcp import agent_mcp

# Drop your files in src/deep_research/files/
result = asyncio.run(agent_mcp.ainvoke({
    "researcher_messages": [HumanMessage(content="Summarize the Q3 findings across all reports")]
}))

Configuration

The main knobs to tune are in multi_agent_supervisor.py:

max_researcher_iterations = 6   # Max tool calls per sub-agent
max_concurrent_researchers = 3  # Max parallel research agents per iteration

And model swaps anywhere in the codebase:

# Use Claude for the final report, Gemini for research
supervisor_model = init_chat_model(model="google_genai:gemini-3.1-flash-lite")
writer_model = init_chat_model(model="anthropic:claude-sonnet-4-20250514")

Project Structure

src/deep_research/
β”œβ”€β”€ research_agent_full.py       # Full pipeline: scope β†’ research β†’ report
β”œβ”€β”€ multi_agent_supervisor.py    # Supervisor + parallel researcher coordination
β”œβ”€β”€ research_agent.py            # Individual web search researcher
β”œβ”€β”€ research_agent_mcp.py        # MCP-based local file researcher
β”œβ”€β”€ research_agent_scope.py      # Clarification + brief generation
β”œβ”€β”€ prompts.py                   # All prompt templates
β”œβ”€β”€ state_*.py                   # LangGraph state definitions
└── utils.py                     # Tavily search, think_tool, helpers

Roadmap

  • Streaming output support (token-level for the final report)
  • LangGraph Studio integration with visual graph explorer
  • Persistent memory across sessions
  • Citation verification pass (fact-check sources before including)
  • PDF/document ingestion pipeline for MCP mode
  • Configurable report formats (executive summary, technical deep-dive, bullet brief)

Contributing

Contributions are welcome bug reports, feature ideas, model experiments, prompt improvements, whatever you've got. Open an issue to discuss before large PRs.

This project started as a close study and adaptation of langchain-ai/open_deep_research (MIT licensed). The core supervisor-researcher architecture, graph structure, and several prompt patterns trace back to that work. Credit where it's due.


License

MIT see LICENSE for the full text.


Built by Rudraksh Jani

About

An open-source, multi-agent AI research system built on LangGraph. It uses a supervisor-researcher architecture to autonomously decompose complex queries, run parallel web searches, and synthesize findings into detailed, cited reports.

Topics

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages