A local multi-agent assistant built with LangGraph and Ollama. It routes user queries across specialized agents, uses web search for fresh context, and runs short Python calculations in a restricted process to check numbers.
- 4-agent workflow:
supervisor,researcher,analyst,editor - Multi-model routing:
fast,accurate,auto - Web search tools: SearXNG (primary) + DuckDuckGo (fallback)
- Python tool for calculations: the code is checked before it runs (only a short list of modules
such as
mathandstatistics; noopen,eval,execor system modules; no attributes that start with_) and runs in a separate Python process with an empty environment, a 4-second time limit and capped output. These checks are known to be bypassable. The code is written by a model that reads web pages, so treat it as untrusted: run this tool only inside a container or virtual machine with no network and with memory limits, or turn it off withPYTHON_TOOL=off - 93 unit tests for routing, tools and error cases; they run without Ollama or the internet
flowchart LR
U[User] --> S[Supervisor]
S --> R[Researcher]
S --> A[Analyst]
S --> E[Editor]
R --> A
R --> E
A --> E
E --> O[Final Answer]
- Python
- LangGraph / LangChain
- Ollama (local models)
- SearXNG
python -m venv venv
source venv/bin/activate
pip install -r requirements.txtPull local models (example):
ollama pull deepseek-coder:1.3b
ollama pull qwen3:1.7bSettings are read from environment variables (for example export MODEL_MODE=fast).
The main ones, with their defaults:
| Variable | Default | Meaning |
|---|---|---|
MODEL_FAST |
deepseek-coder:1.3b |
Small, fast Ollama model |
MODEL_ACCURATE |
qwen3:1.7b |
Larger Ollama model |
MODEL_MODE |
auto |
auto, fast or accurate |
SEARXNG_URL |
http://localhost:8888/search |
Your SearXNG search endpoint |
SUPERVISOR_MODE |
heuristic |
heuristic: route questions with keyword rules; anything else: ask the model |
EDITOR_MODE |
llm |
deterministic: build news, fact and data reports without the model |
PYTHON_TOOL |
on |
off turns the Python tool off |
PYTHON_MEMORY_LIMIT_MB |
512 |
Memory cap for the Python process (enforced on Linux) |
Web search tries SearXNG first. DuckDuckGo is the fallback: first directly, then through SearXNG,
and last through the r.jina.ai text mirror, a third-party service (set
DUCKDUCKGO_PROXY_PREFIX to change it).
Single query:
python main.py --mode auto "latest AI chip market news"Interactive:
python demo.py --mode autopytest tests/ -v- SearXNG is used as the primary engine because it benchmarked better in this project environment.
- DuckDuckGo remains enabled for fallback resilience.
- LangGraph docs: https://docs.langchain.com/oss/python/langgraph/
- LangGraph repository: https://github.com/langchain-ai/langgraph
- Ollama docs: https://docs.ollama.com/
- SearXNG docs: https://docs.searxng.org/
- SearXNG Search API: https://docs.searxng.org/dev/search_api.html
- SearXNG container installation: https://docs.searxng.org/admin/installation-docker
- Python
astdocs: https://docs.python.org/3/library/ast.html - Python
subprocessdocs: https://docs.python.org/3/library/subprocess.html - FrugalGPT paper (LLM cascades): https://arxiv.org/abs/2305.05176
- RouteLLM paper (LLM routing): https://arxiv.org/abs/2406.18665
https://gerred.github.io/building-an-agentic-system/core-architecture.html https://medium.com/@anil.goyal0057/building-a-powerful-ai-agent-using-langchain-mistral-faiss-and-web-search-c9953751a1b2 https://medium.com/@elmo92/search-in-peace-with-searxng-an-alternative-search-engine-that-keeps-your-searches-private-accd8cddd6fc