A Multi-Agent AI Research System Powered by LangChain
Four specialized AI agents collaborate in a pipeline โ searching, scraping, writing, and critiquing โ to deliver polished research reports on any topic in minutes.
- Overview
- Architecture
- Agent Pipeline
- Tech Stack
- Project Structure
- Getting Started
- Usage
- Example Output
- Key Design Decisions
- Future Enhancements
- License
ResearchMind is a multi-agent AI system that automates the research report generation process. Instead of relying on a single monolithic LLM call, the system decomposes the research task into four distinct stages, each handled by a specialized agent or chain. This separation-of-concerns approach produces higher-quality outputs, mirrors a real research workflow, and demonstrates core concepts in agentic AI design.
- ๐ Multi-Agent Orchestration โ Four agents collaborate in a sequential pipeline, each with a clear responsibility.
- ๐ ๏ธ Tool-Augmented Agents โ Search and Reader agents are equipped with external tools (web search, URL scraping) for real-time data gathering.
- โ๏ธ Prompt-Engineered Chains โ Writer and Critic use carefully crafted prompt templates for structured, professional output.
- ๐จ Premium UI โ A custom-styled Streamlit interface with real-time pipeline progress tracking, dark theme, and downloadable reports.
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ User Input (Topic) โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโฌโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ
โผ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ AGENT 1 โ Search Agent โ
โ โโโโโโโโโโโโโโโโ โ
โ โ Tavily API โ Searches the web for 5 relevant results โ
โ โโโโโโโโโโโโโโโโ Returns titles, URLs, and snippets โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโฌโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ
โผ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ AGENT 2 โ Reader Agent โ
โ โโโโโโโโโโโโโโโโโโโโ โ
โ โ BeautifulSoup4 โ Scrapes the most relevant URL โ
โ โโโโโโโโโโโโโโโโโโโโ Extracts clean text content (3000ch) โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโฌโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ
โผ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ CHAIN 3 โ Writer Chain โ
โ Prompt Template โ GPT-4o-mini โ StrOutputParser โ
โ Produces a structured report: Intro, Findings, Conclusion โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโฌโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ
โผ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ CHAIN 4 โ Critic Chain โ
โ Prompt Template โ GPT-4o-mini โ StrOutputParser โ
โ Scores the report (X/10), lists strengths and improvements โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโฌโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ
โผ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ ๐ Final Report + ๐ง Critic Feedback โ
โ (Displayed in UI & downloadable as .md) โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
| Stage | Component | Type | Tool / Technique | Purpose |
|---|---|---|---|---|
| 01 | Search Agent | LangChain Agent | Tavily Web Search API | Queries the web and retrieves the top 5 relevant results with titles, URLs, and snippets |
| 02 | Reader Agent | LangChain Agent | BeautifulSoup4 URL Scraper | Selects the best URL from search results and scrapes clean, readable text content |
| 03 | Writer Chain | LangChain LCEL Chain | Prompt โ LLM โ Parser | Synthesizes search results + scraped content into a structured research report |
| 04 | Critic Chain | LangChain LCEL Chain | Prompt โ LLM โ Parser | Reviews the report and provides a score (X/10), strengths, weaknesses, and a verdict |
| Category | Technology | Purpose |
|---|---|---|
| LLM Framework | LangChain | Agent creation, prompt templates, LCEL chains, tool integration |
| Language Model | OpenAI GPT-4o-mini | Core reasoning engine for all agents and chains |
| Web Search | Tavily API | Real-time web search optimized for AI agents |
| Web Scraping | BeautifulSoup4 + Requests | HTML parsing and clean text extraction from URLs |
| Frontend | Streamlit | Interactive web UI with custom CSS theming |
| Environment | python-dotenv | Secure API key management via .env file |
| Language | Python 3.10+ | Core programming language |
Multi-agent-research-system/
โ
โโโ app.py # Streamlit web UI โ custom-styled frontend with
โ # real-time pipeline progress, result display,
โ # and .md report download
โ
โโโ agents.py # Agent & chain definitions
โ # - build_search_agent() โ LangChain agent w/ Tavily tool
โ # - build_reader_agent() โ LangChain agent w/ scraper tool
โ # - writer_chain โ LCEL prompt | LLM | parser
โ # - critic_chain โ LCEL prompt | LLM | parser
โ
โโโ tools.py # Custom LangChain tools
โ # - web_search() โ Tavily API wrapper
โ # - scrape_url() โ BeautifulSoup4 URL scraper
โ
โโโ pipeline.py # CLI pipeline runner โ runs all 4 stages sequentially
โ # and prints results to the terminal
โ
โโโ requirements.txt # Python dependencies
โโโ .env # API keys (OPENAI_API_KEY, TAVILY_API_KEY)
โโโ .gitignore # Excludes .env from version control
- Python 3.10 or higher
- An OpenAI API key
- A Tavily API key (free tier available)
# 1. Clone the repository
git clone https://github.com/yourusername/Multi-agent-research-system.git
cd Multi-agent-research-system
# 2. Create and activate a virtual environment
python -m venv venv
source venv/bin/activate # macOS / Linux
venv\Scripts\activate # Windows
# 3. Install dependencies
pip install -r requirements.txt
# 4. Set up environment variables
# Create a .env file in the project root:
echo "OPENAI_API_KEY=your_openai_api_key_here" > .env
echo "TAVILY_API_KEY=your_tavily_api_key_here" >> .envstreamlit run app.pyThis launches a polished dark-themed web interface where you can:
- Enter any research topic
- Watch the 4-stage pipeline execute in real-time with status indicators
- View the final report rendered as formatted Markdown
- Read the critic's feedback and score
- Download the complete report as a
.mdfile
python pipeline.pyThis runs the same 4-agent pipeline directly in the terminal with step-by-step output logging.
Input Topic: "LLM agents 2025"
Finds the top 5 web results with titles, URLs, and content snippets from Tavily.
Automatically selects the most relevant URL and extracts up to 3,000 characters of clean text.
# Research Report: LLM Agents in 2025
## Introduction
Large Language Model (LLM) agents have emerged as one of the most
transformative developments in artificial intelligence...
## Key Findings
1. **Agentic Frameworks Are Maturing** โ LangChain, CrewAI, and AutoGen...
2. **Tool-Use Is Becoming Standard** โ Modern agents integrate search, code...
3. **Multi-Agent Systems Show Promise** โ Collaborative agent architectures...
## Conclusion
The trajectory of LLM agents in 2025 suggests a shift from...
## Sources
- https://example.com/llm-agents-2025
- https://example.com/ai-research-trendsScore: 8/10
Strengths:
- Well-structured with clear section divisions
- Cites specific technologies and frameworks
- Professional and balanced tone
Areas to Improve:
- Could include more quantitative data
- Missing discussion of limitations and risks
One line verdict:
A solid, well-researched report that would benefit from deeper statistical analysis.
- Iterative refinement loop โ Feed critic feedback back to the writer for automatic report improvement
- Multi-source scraping โ Scrape multiple URLs in parallel for richer research material
- PDF export โ Generate downloadable PDF reports alongside Markdown
- Citation formatting โ Auto-format references in APA / IEEE style
- Memory / conversation โ Allow follow-up questions on generated reports
- Support additional LLMs โ Add support for Anthropic Claude, Google Gemini, and open-source models
This project is open source and available under the MIT License.
Built with โค๏ธ using LangChain, OpenAI, and Streamlit