A multi-agent system that uses AI agents to perform comprehensive web research, synthesize findings into detailed reports, and deliver them via email.
DeepResearch is a multi-agent system that automates the entire research workflow:
- Planning: An AI planner agent analyzes your query and creates a strategic search plan
- Searching: Multiple web searches are performed in parallel based on the plan
- Synthesis: A writer agent compiles all findings into a comprehensive markdown report
- Delivery: The final report is automatically sent via email
The system features a user-friendly Gradio web interface for easy interaction and provides real-time progress updates throughout the research process.
See the DeepResearch in action:
The demo shows:
- Entering a research query in the Gradio interface
- Real-time progress updates as searches are planned and executed
- The final comprehensive report being generated and displayed
- Email delivery confirmation
The system consists of four specialized AI agents working together:
- Analyzes your research query
- Generates a strategic plan with multiple search terms (default: 5 searches)
- Provides reasoning for each search query
- Uses GPT-5-mini model for efficient planning
- Performs web searches using OpenAI's WebSearchTool
- Summarizes search results into concise 2-3 paragraph summaries
- Executes searches in parallel for faster results
- Uses GPT-5-mini model with required tool usage
- Synthesizes all search results into a cohesive report
- Creates detailed markdown reports (5-10 pages, 1000+ words)
- Generates a short summary and follow-up questions
- Uses GPT-5-mini model for report generation
- Formats the report into clean HTML
- Sends the report via SendGrid email service
- Creates appropriate subject lines
- Multi-agent architecture: specialized agents for each stage of research
- Parallel web searching: multiple searches executed simultaneously
- Comprehensive reports: cetailed markdown reports with summaries and follow-up questions
- Email delivery: automatic email delivery via SendGrid
- Web interface: user-friendly Gradio UI with real-time updates
- Traceability: OpenAI trace links for debugging and monitoring
- Python 3.12+: core programming language
- OpenAI Agents SDK: AI agent framework for multi-agent orchestration
- Gradio: web interface framework for interactive UI
- SendGrid: email delivery service for report distribution
- python-dotenv: environment variable management
- Pydantic: data validation and settings management
- Python 3.12 or higher
- OpenAI API key
- SendGrid API key (for email functionality)
- Environment variables configured (see Installation)
git clone <repository-url>
cd deep-research-agentpython -m venv venv
source venv/bin/activate # On Windows: venv\Scripts\activateUsing uv (recommended):
uv pip install -r requirements.txtOr using pip:
pip install -r requirements.txtCreate a .env file in the project root with the following variables:
OPENAI_API_KEY=your_openai_api_key_here
SENDGRID_API_KEY=your_sendgrid_api_key_here
EMAIL_FROM=your_sender_email@example.com
EMAIL_TO=your_recipient_email@example.comNote: Make sure to add .env to your .gitignore file to keep your API keys secure.
- OpenAI API Key: Sign up at OpenAI Platform and create an API key
- SendGrid API Key: Sign up at SendGrid and create an API key in Settings > API Keys
Start the Gradio web interface:
python deep_research.pyThe interface will open in your browser at http://127.0.0.1:7860. Enter your research query in the text box and click "Run" or press Enter.
You can also use the ResearchManager class directly in your Python code:
import asyncio
from research_agents.research_manager import ResearchManager
async def main():
manager = ResearchManager()
query = "What are the latest developments in quantum computing?"
async for update in manager.run(query):
print(update)
asyncio.run(main())deep-research/
├── deep_research.py # Main entry point with Gradio UI
├── research_agents/
│ ├── __init__.py
│ ├── research_manager.py # Orchestrates the research workflow
│ ├── planner_agent.py # Plans search queries
│ ├── search_agent.py # Performs web searches
│ ├── writer_agent.py # Generates reports
│ └── email_agent.py # Sends email reports
├── pyproject.toml # Project configuration
├── requirements.txt # Python dependencies
├── LICENSE # MIT License
└── README.md # This file
Edit research_agents/planner_agent.py to change the HOW_MANY_SEARCHES constant:
HOW_MANY_SEARCHES = 3 # Change this valueAll agents currently use gpt-5-mini. To use different models, update the model parameter in each agent file:
planner_agent = Agent(
name="Planner Agent",
instructions=instructions,
model=("gpt-4o"), # Change model here
output_type=WebSearchPlan,
)- Verify your SendGrid API key is correct
- Check that
EMAIL_FROMandEMAIL_TOare valid email addresses - Ensure your SendGrid account is verified
- Check SendGrid dashboard for any delivery issues
- Verify your OpenAI API key is valid and has sufficient credits
- Check your internet connection
- Review the trace link provided in the console output for detailed error information
- Ensure all dependencies are installed:
pip install -r requirements.txt - Verify you're using Python 3.12 or higher
- Check that you're in the correct virtual environment
This project is licensed under the MIT License - see the LICENSE file for details.
