(CI installs the backend and runs one self-contained check; a second workflow lints and builds the frontend)
A full run in the app. Agents work in stages, the fact checker pauses for a human decision, then the report and charts appear. It was recorded locally with a stand-in model and canned search results, so the chart values are illustrative.
Seven LangGraph agents that research companies, fact-check the findings and write a comparison report with charts.
Demo: a live copy is at https://multi-agent-research-frontend.vercel.app (no login). The API behind it sleeps on a free host, so the first load can take about half a minute, and a run takes two to four minutes. A full run on it (Shopify against BigCommerce, basic depth) finished in under four minutes with a written report and four charts. It was built for free tiers (Groq, Tavily), so a run can hit Groq's free-tier limits and slow down or fail. Everything also runs locally from the steps below.
You give it a query and a list of companies. A coordinator agent plans the research. Two agents gather web and financial data in parallel. An analyst builds SWOT and feature comparisons. A fact checker reviews the claims. Two more agents write the report and generate chart specs in parallel. Progress streams to the browser over a WebSocket while it runs. The result can be downloaded as PDF, Markdown or JSON.
- Agents: 7, with two parallel stages (research, then output)
- Human in the loop: one gate, in the fact checker (see below)
- Stack: LangGraph, FastAPI, Next.js 16, Groq (Ollama for local development), Redis, Chart.js, tiktoken
- Cost: runs on free tiers (Groq, Tavily, Render, Vercel), with Redis optional
In early September 2026 Groq retired the llama-3.3-70b-versatile model name. This demo and the Enterprise RAG service it calls both started failing within a day of each other. Every agent I watched died on a raw model_not_found error. The fix was to make the model a setting (DEFAULT_LLM_MODEL, default openai/gpt-oss-120b). The next retirement is now an environment variable change instead of a code change.
That same week I found the content synthesizer could never succeed on the free tier. Its two calls asked for roughly eleven thousand tokens against a per-minute ceiling of eight thousand. The token budgets are now named constants in content_synthesizer.py. A rate-limited agent now moves to the next model in FALLBACK_LLM_MODELS, because Groq's quotas are per model. Once that list is used up, it waits as long as Groq asks.
| Agent | Role | Tools | Execution |
|---|---|---|---|
| Coordinator | Plans the run: objectives, search priorities, financial priorities, comparison angles, depth per agent | LLM with JSON output | Sequential |
| Web Research | Gathers competitive intelligence using the coordinator's search priorities | Tavily, DuckDuckGo, search cache, page scraping, Enterprise RAG API | Parallel with Financial |
| Financial Intelligence | Researches funding, revenue and growth | Tavily, DuckDuckGo, search cache, page scraping | Parallel with Web |
| Data Analyst | SWOT and feature matrix, using the coordinator's comparison angles | LLM over web and financial data | Sequential |
| Fact Checker | Reviews the analysis and can pause the run for a human decision | LLM, approval gate | Sequential |
| Content Synthesizer | Writes the summary and the full report around the coordinator's objectives | LLM, two calls | Parallel with Data Viz |
| Data Visualization | Produces Chart.js specs (bar, line, pie, doughnut) for the frontend | LLM | Parallel with Synthesizer |
The coordinator's output is used, not decorative. Its priorities become the search queries. Its comparison angles go into the analyst's prompt. Its objectives frame the report. Its depth settings (light, standard, comprehensive) change how many queries, results, RAG chunks and scraped pages each agent uses.
There is exactly one. After the fact checker writes its report, the backend looks for the words "unverified", "could not verify", "insufficient evidence" or "contradictory". If any appear, the run pauses. The browser shows an approval modal with a preview of the report and two choices, continue or stop. If nobody answers within 300 seconds, the run continues. If the approval mechanism itself errors, the run also continues.
User query + companies
|
v
FastAPI (main.py): LangGraph, WebSocket updates, rate limiting
|
v
Coordinator
|
+-------------------+
v v
Web Research Financial Intel (parallel stage 1)
| |
+---------+---------+
v
Data Analyst
|
v
Fact Checker <---- approval gate (continue or stop)
|
+---------+---------+
v v
Content Synthesizer Data Viz (parallel stage 2)
| |
+---------+---------+
v
Report, charts, PDF / Markdown / JSON export
I have not timed the stages, so the diagram carries no durations. Run time depends on the model, the depth setting and Groq's rate limits.
All agents share one MarketResearchState (a TypedDict). Fields that parallel agents write to (research_findings, current_agent, cost_tracking, errors, fact_check_results, visualizations) are declared Annotated[List[...], operator.add]. LangGraph then concatenates what each branch returns instead of letting one overwrite the other. Fields that only one agent writes (competitor_profiles, financial_data, final_report) are plain.
Prerequisites: Python 3.11+, Node.js 20.9+ (CI runs 22), and either a Groq API key or a local Ollama.
cd backend
python -m venv venv
source venv/bin/activate # Windows: .\venv\Scripts\activate
pip install -r requirements.txt
cp .env.example .env
# Add GROQ_API_KEY. Add TAVILY_API_KEY for better search (DuckDuckGo is the fallback).
python -m app.mainThe server runs at http://localhost:8000. In development it uses Ollama, so start Ollama. The Groq fallback does not run if Ollama is down. With ENVIRONMENT=production it uses Groq only. It requires both GROQ_API_KEY and TAVILY_API_KEY.
cd frontend
npm install
cp .env.example .env.local # defaults work for local development
npm run devThe frontend runs at http://localhost:3000.
curl -X POST http://localhost:8000/api/research \
-H "Content-Type: application/json" \
-d '{
"query": "Compare Notion vs Coda vs ClickUp",
"companies": ["Notion", "Coda", "ClickUp"],
"analysis_depth": "standard"
}'| Method | Endpoint | Description | Rate limit |
|---|---|---|---|
| GET | /health |
Health check | None |
| GET | /api/cache/stats |
Search cache hits, misses and backend in use | None |
| GET | /api/llm/health |
Which LLM provider and model is active | None |
| POST | /api/research |
Start a research run | 5 per minute per IP |
| POST | /api/approval/respond |
Answer the approval gate | None |
| GET | /api/approval/pending/{session_id} |
List pending approvals | None |
| GET | /docs, /redoc |
Swagger and ReDoc | None |
WS /ws/research/{session_id} streams workflow_started, agent_status, approval_request, approval_received, workflow_complete and workflow_failed.
Backend .env:
GROQ_API_KEY=your_groq_key # required in production
TAVILY_API_KEY=your_tavily_key # required in production, optional in development
REDIS_URL=your_redis_url # optional, an in-memory cache is used without it
ENVIRONMENT=development # or production
# Optional: override the Groq model. Set this when Groq retires one.
# DEFAULT_LLM_MODEL=openai/gpt-oss-120b
# Optional: models to move to when the default is rate limited (comma separated).
# FALLBACK_LLM_MODELS=openai/gpt-oss-20b,qwen/qwen3.8-27bOther settings (RAG_API_URL, OLLAMA_BASE_URL, LOG_LEVEL, CACHE_TTL, MAX_PARALLEL_AGENTS, AGENT_TIMEOUT) have defaults in backend/app/core/config.py.
Frontend .env.local:
NEXT_PUBLIC_API_URL=http://localhost:8000
NEXT_PUBLIC_WS_URL=ws://localhost:8000- Search cache. Search results are cached for one hour (
CACHE_TTL), in Redis whenREDIS_URLis set and in memory otherwise. - Rate limit.
/api/researchallows 5 requests per minute per IP, which protects the Tavily and Groq quotas. - Retries. Each agent makes up to 5 attempts. When the default model is rate limited, the agent moves to the next model in
FALLBACK_LLM_MODELS. Once that list is used up, or for any other error, it waits before retrying. The wait is as long as Groq says when it says (capped at 30 seconds). Otherwise it is 1, 2, 4 and 8 seconds. - Token counting. tiktoken counts tokens for the cost tracking and for truncating prompts to fit the model's per-minute budget.
- RAG. The web research agent asks the Enterprise RAG Knowledge Base for existing knowledge and carries on without it when that service is unavailable or slow.
- Fail-fast config. The backend refuses to start in production without its API keys.
The backend ships as a Docker image, so deploy it as a Docker web service. There is no render.yaml.
- Create a new Web Service on https://dashboard.render.com and connect this repository.
- Set the runtime to Docker, with Dockerfile path
./backend/Dockerfileand build context./backend. - Add
GROQ_API_KEYandTAVILY_API_KEY, optionallyREDIS_URL, and setENVIRONMENT=production. - Deploy. The container exposes port 8000 and a
/healthcheck.
cd frontend
vercel --prod --yesSet NEXT_PUBLIC_API_URL and NEXT_PUBLIC_WS_URL (wss://) to the backend URL before building.
multi-agent-research/
├── backend/
│ ├── app/
│ │ ├── agents/ # one file per agent, plus base.py, state.py, graph.py
│ │ │ └── tools/ # search.py (Tavily, DuckDuckGo, scraper), rag_client.py
│ │ ├── api/ # schemas.py, websocket.py
│ │ ├── core/ # config.py, llm.py, tokens.py
│ │ ├── services/ # cache.py, hitl_manager.py
│ │ └── main.py # FastAPI app and rate limiting
│ ├── test_api.py # smoke test, needs a running backend
│ ├── test_output_limit.py # 3 offline asserts, run by CI
│ ├── requirements.txt
│ └── Dockerfile
├── frontend/
│ └── src/
│ ├── app/ # home form, live research page
│ ├── components/ # AgentCard, ChartRenderer, ApprovalModal
│ ├── hooks/ # useWebSocket.ts
│ └── utils/ # pdfExport.ts (jsPDF, html2canvas)
├── README.md
└── SYSTEM-KNOWLEDGE.md # design notes
Two scripts. backend/test_output_limit.py is 3 offline asserts and the only thing CI runs. backend/test_api.py is a smoke test. With the backend running, it posts a research request to http://localhost:8000 and prints the session id and status. It does not open the WebSocket, so it does not wait for or print the report. There are no unit tests for the agents.
cd backend
python test_api.py- Backend will not start: check that Ollama is running (
curl http://localhost:11434/api/tags) or setENVIRONMENT=productionwithGROQ_API_KEYandTAVILY_API_KEYin.env. Python 3.11 or newer is required. - A run fails with a model error: the configured Groq model may have been retired. Set
DEFAULT_LLM_MODELto one Groq currently serves. - Frontend cannot connect: check
NEXT_PUBLIC_API_URLand the CORS origins inbackend/app/core/config.py. - WebSocket will not connect: use
ws://against http andwss://against https, and check the session id.
- Unit and integration tests for the agents, beyond the smoke test and the 3 output limit asserts.
- Authentication and per-user accounts.
- Storing past research and making it searchable (search results are cached today).
MIT, see LICENSE.
