An autonomous multi-agent AI system that decomposes research topics into atomic claims, retrieves live web evidence, verifies factual accuracy, detects source contradictions, and synthesizes structured research reports.
Verifying complex claims online means cross-checking multiple sources, spotting contradictions, and organizing findings β all manually. Single-prompt LLMs can't do this reliably without real-time web access and structured reasoning.
The Autonomous Multi-Agent Research & Fact Verification System fixes this with a 5-agent LangGraph pipeline backed by FastAPI, powered by live web search (Tavily), vector similarity search (FAISS + SentenceTransformers), and your choice of Gemini, OpenAI, or Claude.
- Stateful Multi-Agent Orchestration β 5 specialized agents coordinated in a LangGraph DAG
- Provider-Agnostic LLM Engine β Switch between Gemini, OpenAI, and Claude per request
- Live Web Search & RAG β Real-time evidence retrieval via Tavily Search API
- Local Vector Embeddings β
sentence-transformers/all-MiniLM-L6-v2(384-dim dense vectors) - Session-Isolated FAISS Vector DB β Fast in-memory semantic similarity search
- Contradiction Detection β Flags numerical mismatches and reporting conflicts across sources
- MongoDB Atlas Persistence β Async job tracking and historical analysis via Motor
| Component | Technology | Purpose |
|---|---|---|
| Framework | FastAPI >=0.110.0 |
Async REST API with OpenAPI docs |
| Language | Python 3.10+ | Backend runtime |
| Agent Orchestration | LangGraph >=0.0.30 |
Stateful multi-agent DAG workflow |
| LLM Integrations | LangChain (google-genai, openai, anthropic) | Provider-agnostic LLM clients |
| Web Search | Tavily Python SDK >=0.3.0 |
Live AI-powered web search |
| Vector DB | FAISS CPU >=1.8.0 |
Similarity search vector index |
| Embeddings | SentenceTransformers | Local text vectorization |
| Database | Motor >=3.3.2 / PyMongo |
Async MongoDB Atlas driver |
| Validation | Pydantic v2 | Request/response schema validation |
+---------------------------------------------------------------+
| FASTAPI BACKEND |
| CORS Middleware Β· Pydantic Validation Β· Exception Handlers |
+---------------------------------------------------------------+
|
v
+---------------------------------------------------------------+
| LANGGRAPH STATEGRAPH WORKFLOW |
| |
| [START] |
| | |
| v |
| 1. Claim Extractor ββ> 2. Search Retriever |
| (LLM Factory) (Tavily + FAISS) |
| | |
| v |
| 4. Contradiction <ββ 3. Fact Verifier |
| Detector (LLM) (LLM Cross-Check) |
| | |
| v |
| 5. Report Generator |
| (LLM Synthesis) |
| | |
| [END] |
+---------------------------------------------------------------+
| | | |
v v v v
LLM Factory Tavily Search FAISS + Embeddings MongoDB Atlas
(Gemini/OpenAI (Live Search) (Local RAG) (Persistence)
/Claude)
multi-agent-fact-verification/
βββ backend/
β βββ app/
β β βββ main.py # FastAPI entrypoint, CORS, exception handlers
β β βββ agents/
β β β βββ claim_extractor.py # Agent 1: Atomic claim extraction
β β β βββ search_retriever.py # Agent 2: Tavily search & FAISS indexing
β β β βββ fact_verifier.py # Agent 3: LLM-based fact verification
β β β βββ contradiction_detector.py # Agent 4: Cross-source contradiction detection
β β β βββ report_generator.py # Agent 5: Markdown report synthesis
β β βββ api/v1/
β β β βββ analyze.py # POST /api/v1/analyze endpoint
β β β βββ health.py # GET /api/v1/health endpoint
β β β βββ router.py # API router aggregation
β β βββ core/
β β β βββ config.py # Pydantic BaseSettings & env config
β β β βββ database.py # Async MongoDB connection manager
β β βββ graph/
β β β βββ builder.py # LangGraph StateGraph assembly
β β β βββ state.py # AgentState TypedDict & domain models
β β βββ schemas/
β β β βββ analyze.py # AnalyzeRequest & AnalyzeResponse schemas
β β βββ services/
β β βββ llm_factory.py # Dynamic LLM client factory
β β βββ tavily_service.py # Tavily search wrapper
β β βββ embedding_service.py # SentenceTransformers vector service
β β βββ faiss_service.py # FAISS vector DB service
β β βββ mongo_service.py # MongoDB async persistence
β βββ .env.example
β βββ requirements.txt
βββ frontend/ # React + Vite dashboard (separate team)
βββ .gitignore
βββ README.md
- Python 3.10, 3.11, or 3.12
- API keys for Google Gemini (or OpenAI/Claude) and Tavily Search
# 1. Navigate to backend
cd backend
# 2. Create and activate virtual environment
python -m venv .venv
# Windows
.\.venv\Scripts\Activate.ps1
# macOS/Linux
source .venv/bin/activate
# 3. Install dependencies
pip install -r requirements.txt
# 4. Configure environment
cp .env.example .env
# Edit .env with your API keyspython -m uvicorn app.main:app --host 127.0.0.1 --port 8000 --reload- API Base URL:
http://127.0.0.1:8000 - Swagger Docs:
http://127.0.0.1:8000/docs
| Variable | Required | Default | Description |
|---|---|---|---|
GOOGLE_API_KEY |
Yes* | "" |
Google Gemini API key |
OPENAI_API_KEY |
Optional | "" |
OpenAI API key |
ANTHROPIC_API_KEY |
Optional | "" |
Anthropic Claude API key |
TAVILY_API_KEY |
Yes | "" |
Tavily Search API key |
MONGODB_URI |
Yes | "mongodb://localhost:27017" |
MongoDB connection URI |
DEFAULT_LLM_PROVIDER |
No | "gemini" |
Default provider (gemini, openai, claude) |
GEMINI_MODEL_NAME |
No | "gemini-3.1-flash-lite" |
Gemini model string |
OPENAI_MODEL_NAME |
No | "gpt-4o" |
OpenAI model string |
CLAUDE_MODEL_NAME |
No | "claude-3-5-sonnet-20241022" |
Claude model string |
MONGODB_DB_NAME |
No | "fact_verification_db" |
MongoDB database name |
*Required only when using Gemini as the provider.
{
"query": "Did renewable energy generate more than 30% of global electricity in 2024?",
"model_provider": "gemini"
}| Parameter | Type | Required | Description |
|---|---|---|---|
query |
string |
Yes | Research claim or question (5β1000 chars) |
model_provider |
string |
No | "gemini", "openai", or "claude" |
{
"job_id": "job_d40409a473",
"status": "completed",
"query": "Did renewable energy generate more than 30% of global electricity in 2024?",
"claims": [
{
"id": "claim_01",
"text": "Renewable energy generated over 30% of global electricity in 2024.",
"verdict": "SUPPORTED",
"confidence": 0.95,
"reasoning": "Ember Global Electricity Review 2025 confirms renewables reached 32% in 2024."
}
],
"sources": [
{
"id": "src_01",
"url": "https://ember-climate.org/insights/research/global-electricity-review-2025/",
"title": "Global Electricity Review 2025 | Ember",
"snippet": "Clean electricity generated 40% of global power in 2024..."
}
],
"contradictions": [],
"report_markdown": "# Fact Verification Report...",
"errors": []
}[START] β Claim Extractor β Search Retriever β Fact Verifier β Contradiction Detector β Report Generator β [END]
- Claim Extractor β Breaks the user query into atomic, testable claim statements
- Search Retriever β Queries Tavily for live web results, embeds snippets into a FAISS index
- Fact Verifier β Cross-checks each claim against retrieved evidence; assigns
SUPPORTED,REFUTED, orINCONCLUSIVEwith a confidence score - Contradiction Detector β Identifies numerical mismatches and reporting conflicts across sources
- Report Generator β Synthesizes all findings into a structured Markdown research report