A semi-autonomous agent using the Router Pattern in LangGraph.
The graph routes user queries to one of two specialist agents:
- RAG Agent — answers questions grounded in your vector store
- Web Search Agent — answers questions requiring fresh / real-time information via Tavily
User Query
│
▼
[Router Node] ──── "rag" ──► [RAG Agent Node] ──► [Output]
└── "web" ──► [Web Search Agent Node] ──► [Output]
- Ollama installed and running with
qwen2.5model - Tavily API Key (for web search functionality)
-
Install Ollama: Download from ollama.ai
-
Pull Qwen2.5 model:
ollama pull qwen2.5
-
Start Ollama server (if not already running):
ollama serve
This will start at
http://localhost:11434by default. -
Set up the project:
cd /path/to/langgraph-router-agent cp .env.example .env # Edit .env and add your TAVILY_API_KEY
-
Install dependencies using uv:
uv sync
uv run python -m src.mainOr use the script entry point:
uv run langgraph-routersrc/
config/ – env & model settings
graph/ – LangGraph state, nodes, edges, compiled graph
agents/ – RAG agent & Web Search agent logic
tools/ – Tavily tool wrapper, RAG retriever wrapper
utils/ – shared helpers (logging, prompt builders)
tests/ – pytest test suite