ResearchFlow AI is a production-grade agentic research system that decomposes complex questions into sub-queries, retrieves and verifies web evidence, and synthesizes citation-grounded answers β with self-correcting retry logic when evidence quality is low.
Ask any complex research question β ResearchFlow decomposes it, searches for evidence, verifies quality, and returns a cited answer with a full reasoning trace.
Most LLM apps do: question β retrieve β answer
ResearchFlow does:
question β decompose β search β verify confidence β
if low: re-search with refined query (cyclic retry) β
answer with citations + reasoning trace
This is agentic reasoning β the system evaluates its own evidence quality and decides whether to retry before synthesizing. Single-prompt LLM systems hallucinate. ResearchFlow verifies.
graph TD
A[User Query] --> B[Planner Node]
B --> C[Decomposer Node]
C --> D[Search Node - Tavily]
D --> E[Verifier Node]
E -->|confidence < threshold| D
E -->|confidence β₯ threshold| F[Synthesizer Node]
F --> G[Citation-Grounded Answer]
| Node | Role |
|---|---|
| Planner | Analyzes query intent, defines research strategy |
| Decomposer | Breaks complex question into focused sub-queries |
| Search | Retrieves web evidence via Tavily Search API |
| Verifier | Scores evidence relevance and confidence (0β1) |
| Synthesizer | Generates final answer with inline citations |
The cyclic edge between Verifier and Search is the core innovation β if confidence falls below threshold, the system refines the query and searches again rather than hallucinating from weak evidence.
Query: "How does LangGraph enable self-correcting AI agents?"
Pipeline trace:
[Planner] β Strategy: technical documentation + recent examples
[Decomposer] β Sub-queries: ["LangGraph cyclic workflow",
"LangGraph conditional routing",
"LangGraph stateful agents retry"]
[Search] β Retrieved 9 sources via Tavily
[Verifier] β Confidence: 0.44 (below threshold) β RETRY
[Search] β Refined query: "LangGraph self-correction checkpointing 2024"
[Verifier] β Confidence: 0.83 β PASS
[Synthesizer] β Answer with 5 inline citations
Sample output:
β’ LangGraph enables self-correcting agents through cyclical workflows where
an agent generates output, evaluates results, and loops back for revision.
β’ It maintains shared state and checkpoints so intermediate results persist
across iterations.
β’ Conditional routing allows workflows to retry, revise, or terminate
execution based on intermediate outcomes.
Limitation: LangGraph provides orchestration infrastructure, but evaluation
logic must still be implemented by the developer.
- Python 3.10+
- Ollama running locally with Llama 3.2:
ollama pull llama3.2 - Tavily API key (free tier at tavily.com)
git clone https://github.com/krishnakoushik225/langgraph-research-agent
cd langgraph-research-agent
python -m venv .venv
source .venv/bin/activate # Windows: .venv\Scripts\activate
pip install -r requirements.txtcp .env.example .env
# Add your keys:
# TAVILY_API_KEY=your_key_here
# LANGSMITH_API_KEY=your_key_here (optional, for tracing)# Backend
uvicorn app.main:app --reload
# Runs at http://127.0.0.1:8000
# Frontend (separate terminal)
cd frontend && npm install && npm start
# Runs at http://localhost:3000| Layer | Technology |
|---|---|
| Agent Orchestration | LangGraph (cyclic state machine) |
| LLM Backend | Ollama + Llama 3.2 (local, private) |
| Web Search | Tavily Search API |
| API Backend | FastAPI (async) |
| Frontend | React + Axios |
| Observability | LangSmith (optional tracing) |
langgraph-research-agent/
βββ backend/
β βββ app/
β βββ graph/
β β βββ planner.py # Research strategy generation
β β βββ decomposer.py # Sub-question generation
β β βββ search.py # Tavily evidence retrieval
β β βββ verifier.py # Confidence scoring + retry logic
β β βββ synthesizer.py # Citation-grounded answer generation
β βββ services/
β β βββ ollama_client.py # Local LLM client
β βββ main.py # FastAPI entrypoint
βββ frontend/
β βββ src/
β βββ App.jsx
β βββ App.css
βββ docs/
β βββ researchflow-demo.png
β βββ architecture.png
βββ .env.example
βββ requirements.txt
βββ README.md
Evidence Quality β Web search returns noisy results. The Verifier node assigns a confidence score and triggers re-search with refined queries when quality is low.
Hallucination Prevention β The Synthesizer is constrained to generate answers only from retrieved evidence, with every claim linked to a source.
Agent Coordination β LangGraph manages shared workflow state across all nodes, enabling conditional branching and retry without losing intermediate results.
Adaptive Research β If initial sub-questions yield weak evidence, the system reformulates them before attempting synthesis.
LangGraph was chosen specifically because it supports cyclic graphs β standard LangChain chains are DAGs (directed acyclic graphs) and cannot model retry loops. LangGraph enables:
- Stateful workflows β shared research state persists across all nodes
- Conditional routing β retry, revise, or terminate based on verifier output
- Modular reasoning nodes β each node has a single, testable responsibility
- Checkpointing β intermediate results survive failures and restarts
- LangSmith full trace dashboard
- Human-in-the-loop checkpoint before synthesis
- Vector database retrieval (Pinecone) as additional search source
- Streaming tokens to frontend in real-time
- Multi-model support (GPT-4, Claude, Gemini)
- Multi-agent collaboration mode
MIT β free to use and build on.
Built by Krishna Koushik Unnam Β· AI Systems Developer
