How langchain-ai/rag-research-agent-template works
This is a LangGraph RAG research-agent template with separate document-indexing and conversational-retrieval graphs. Indexing accepts documents (or configured sample documents) and adds them to a selected vector store. For questions, the retrieval graph classifies intent, requests clarification or declines out-of-scope questions, or creates a research plan; its researcher subgraph generates parallel search queries, retrieves documents, and returns them for a context-grounded response. Configuration, prompts, and shared document state support these workflows. Relationships follow the README and shown call sites; external model and vector-store connections are represented at the integration boundary.
Main entry points: retrieval_graph/graph.py Retrieval graph · retrieval.py Retriever factory · index_graph/graph.py Index graph · researcher_graph/graph.py Researcher graph
Components 21
Document indexing
- Index graph
src/index_graph/graph.py - Index settings
src/index_graph/configuration.py - Index state
src/index_graph/state.py
Conversation workflow
- Retrieval graph
src/retrieval_graph/graph.py - Agent settings
src/retrieval_graph/configuration.py - Agent prompts
src/retrieval_graph/prompts.py - Conversation state
src/retrieval_graph/state.py
Research subgraph
- Researcher graph
src/retrieval_graph/researcher_graph/graph.py - Research state
src/retrieval_graph/researcher_graph/state.py
Shared services
- Retriever factory
src/shared/retrieval.py - Base configuration
src/shared/configuration.py - Document reducer
src/shared/state.py - Chat model loader
src/shared/utils.py - Document formatter
src/shared/utils.py
Other components
- User
- Document source
- Chat model provider
- Embedding provider
- Elasticsearch
- Pinecone
- MongoDB Atlas
Connections 24
- Document source → Index graph: supplies documents
README.md - Index graph → Retriever factory: adds documents
src/index_graph/graph.py - Index graph → Index settings: loads settings
src/index_graph/graph.py - Index graph → Document reducer: normalizes sample docs
src/index_graph/graph.py - Index state → Document reducer: reduces documents
src/index_graph/state.py - User → Retrieval graph: submits query
README.md - Retrieval graph → Conversation state: maintains conversation
src/retrieval_graph/graph.py - Retrieval graph → Agent settings: loads settings
src/retrieval_graph/graph.py - Agent settings → Agent prompts: uses defaults
src/retrieval_graph/configuration.py - Retrieval graph → Chat model loader: loads models
src/retrieval_graph/graph.py - Chat model loader → Chat model provider: initializes
src/shared/utils.py - Retrieval graph → Researcher graph: invokes per plan step
src/retrieval_graph/graph.py - Researcher graph → Research state: uses research state
src/retrieval_graph/researcher_graph/graph.py - Researcher graph → Chat model loader: loads query model
src/retrieval_graph/researcher_graph/graph.py - Researcher graph → Retriever factory: retrieves documents
src/retrieval_graph/researcher_graph/graph.py - Retrieval graph → Document formatter: formats retrieved context
src/retrieval_graph/graph.py - Retrieval graph → Document reducer: reduces documents
- Research state → Document reducer: reduces documents
src/retrieval_graph/researcher_graph/state.py - Retriever factory → Base configuration: resolves settings
src/shared/retrieval.py - Retriever factory → Embedding provider: creates embeddings
src/shared/retrieval.py - Retriever factory → Elasticsearch: configures retriever
src/shared/retrieval.py - Retriever factory → Pinecone: configures retriever
src/shared/retrieval.py - Retriever factory → MongoDB Atlas: configures retriever
src/shared/retrieval.py - Index graph → Document source: loads sample fallback
README.md