Workflow

Auditable Deep Research Pipeline with LangGraph and Exa

A LangGraph state machine that decomposes a research question into sub-questions, finds sources with Exa semantic search, extracts and reranks passages, and writes an executive report with citations — auditable and private enough for finance or legal due diligence.

What This Builds

This recipe builds a deep research pipeline modeled as an explicit LangGraph state machine rather than a single prompt. A shared ResearchState flows through specialized nodes — planner, searcher, fetcher, ranker, writer — each adding to a growing “research folder” until a cited executive report comes out the other end.

The concrete use case is due diligence: a VC or analyst pastes a question (“competitive landscape for X”), and the pipeline returns a structured memo with a logged evidence trail. Because every step is a node, you get retries, checkpoints, and source transparency — the things that matter when research has to be defensible for compliance or investment decisions.

The Stack

  • LangChain / LangGraph — models the workflow as a StateGraph: nodes mutate shared state and edges define the flow, so you can retry or expand a single stage without rewriting the pipeline.
  • Exa — AI-native semantic search that understands meaning, not just keywords; the searcher node uses it with domain and recency filters to find authoritative sources per sub-question.
  • Cohere Rerank — the ranker node reranks fetched passages against the original query so only the most relevant text reaches the writer, cutting fluff and token cost.
  • OpenAI (GPT-4o-class) — the planner that decomposes questions and the writer that synthesizes the final report with [Source: URL] citations.

Step-by-Step Outline

  1. Define a ResearchState Pydantic model holding the question, sub-questions, search queries, sources, passages, and the final report.
  2. Planner node: break the question into 3-7 focused sub-questions and generate search queries (ask clarifying questions if the input is vague).
  3. Searcher node: call Exa per query with recency/domain filters and collect candidate sources.
  4. Fetcher node: download and clean each page (Crawl4AI or Firecrawl), then split into overlapping passages.
  5. Ranker node: rerank passages with Cohere and keep the top slice; Writer node: synthesize a cited executive report.
  6. Wire the nodes into a StateGraph, compile, and invoke; later swap the linear graph for a hub-and-spoke ReAct loop to make it fully agentic.

Why This Shape Works

Modeling research as a graph gives you the reliability deep-research products need: each node is observable and retryable, and the shared state is an auditable evidence trail. Exa’s semantic search finds better sources than keyword APIs, and the Cohere rerank step is what keeps the report grounded in the most relevant passages instead of whatever scrolled by first. Starting linear and upgrading to a ReAct loop later means you ship something working fast.

Source

Sid Bharath, Building a Deep Research Agent with LangGraph And Exa (full code + worksheets): https://sidbharath.com/blog/build-deep-research-agent-langgraph/