Deep Research - AG2
Deep Research
AG2 recommends two approaches for autonomous deep research: the built-in DeepResearchTool and the GPT Researcher multi-agent integration.
DeepResearchTool is a composable AG2 tool that any agent can call directly. It is the right choice when you want research capabilities tightly integrated into your AG2-based agent, without a separate orchestration layer.
GPT Researcher is a standalone research agent with a built-in orchestration pipeline optimized for recursive querying and structured report generation. It is a good choice when you want a pre-built, highly configurable research agent that can operate independently or alongside other AG2 agents.
DeepResearchTool
Inspired by OpenAI's Deep Research, DeepResearchTool is designed to tackle complex, multi-step research tasks, synthesizing insights from diverse online sources.
Installation
DeepResearchTool is built on top of Browser Use, which requires Python 3.11 or higher.
To get started with the DeepResearchTool, follow these steps:
Install AG2 with the
browser-useextra:pip install ag2[openai,browser-use]If you have been using
autogenorag2, all you need to do is upgrade it using:pip install -U autogen[openai,browser-use]or
pip install -U ag2[openai,browser-use]as
autogenandag2are aliases for the same PyPI package.Set up Playwright:
# Installs Playwright and browsers for all OS playwright install # Additional command, mandatory for Linux only playwright install-depsFor running the code in Jupyter, use
nest_asyncioto allow nested event loops.pip install nest_asyncio
You're all set! Now you can start using browsing features in AG2.
Imports
import os
import nest_asyncio
from autogen import AssistantAgent, UserProxyAgent, LLMConfig
from autogen.tools.experimental import DeepResearchTool
nest_asyncio.apply()
Agent Configuration
Configure the agents for the interaction.
config_listdefines the LLM configurations, including the model and API key.UserProxyAgentsimulates user inputs without requiring actual human interaction (set toNEVER).AssistantAgentrepresents the AI agent, configured with the LLM settings.
llm_config = LLMConfig(config_list={
"api_type": "openai",
"model": "gpt-5",
"api_key": os.environ["OPENAI_API_KEY"],
})
user_proxy = UserProxyAgent(name="user_proxy", human_input_mode="NEVER")
assistant = AssistantAgent(name="assistant", llm_config=llm_config)
DeepResearchTool Configuration
Once the DeepResearchTool is created, it needs to be registered to the agents.
deep_research_tool = DeepResearchTool(llm_config=llm_config)
deep_research_tool.register_for_execution(user_proxy)
deep_research_tool.register_for_llm(assistant)
Initiate Chat
result = user_proxy.initiate_chat(
recipient=assistant,
message="What was the impact of DeepSeek on stock prices and why?",
max_turns=2,
)
Response from Assistant
DeepSeek search technology significantly impacted stock prices, particularly in the technology sector, by introducing increased market volatility and substantial fluctuations. Here's a detailed breakdown:
Overview
- Impact of DeepSeek: This AI-driven search technology from China caused disruptions in financial markets, particularly affecting U.S. tech stocks. Its introduction led to massive market capitalization losses, as seen in a trillion-dollar reduction in the Nasdaq index, heavily composed of tech companies.
How DeepSeek Functions
- Cost-Effectiveness and Innovation: DeepSeek's V3 version introduced a highly cost-effective AI model that challenged the existing dominance of international tech firms. This led investors to reevaluate their holdings in these companies, fearing DeepSeek's potential to capture significant market share.
Changes in Stock Prices
- Tech Sector Impact: The technology sector witnessed massive sell-offs, with companies like Nvidia facing severe drops in stock value. The overall tech industry lost billions of dollars following the DeepSeek announcements.
- Software Stocks: Some software stocks, perceived as beneficiaries of this shift, experienced positive investor sentiment contrary to other declining AI stocks.
Mechanisms Influencing Stock Prices
- Market Erosion: DeepSeek’s operational cost advantages and open-source nature disrupted major AI competitors, eroding their market share and prompting a reevaluation of tech stock valuations.
- Valuation Reassessments: Concerns over tech stock valuations heightened market anxiety, driven by competitive threats from DeepSeek.
Conclusion
Overall, DeepSeek challenged tech giants globally, leading to valuation adjustments and increased stock market volatility. This necessitated a broader reassessment of the technological landscape by investors, culminating in significant financial impacts.
GPT Researcher
GPT Researcher is an autonomous research agent that orchestrates a team of specialized agents to produce comprehensive research reports. The AG2 integration uses AG2 as the orchestration layer for the research pipeline.
Research Team
The pipeline coordinates eight specialized agents:
- Chief Editor — manages the team and oversees the research process
- Researcher — conducts autonomous, in-depth topic investigation using GPT Researcher
- Editor — plans the research structure and outline
- Reviewer — validates results against established criteria
- Revisor — refines findings based on reviewer feedback
- Writer — compiles the final report
- Publisher — outputs the report in multiple formats (Markdown, PDF, Docx)
- Human — provides optional oversight and feedback at any stage
Installation
Clone the GPT Researcher repository and install the dependencies:
git clone https://github.com/assafelovic/gpt-researcher.git
cd gpt-researcher
pip install -r requirements.txt
pip install -r multi_agents_ag2/requirements.txt
Environment Setup
export OPENAI_API_KEY={your_openai_key}
export TAVILY_API_KEY={your_tavily_key}
A Tavily API key is required for web search. See Tavily Search Tool for setup details and standalone usage with AG2 agents.
Configure the Research Task
Customize the research task by editing multi_agents_ag2/task.json:
{
"query": "Is AI in a hype cycle?",
"max_sections": 3,
"max_revisions": 3,
"publish_formats": {
"markdown": true,
"pdf": true,
"docx": true
},
"include_human_feedback": false,
"follow_guidelines": false,
"model": "gpt-4o",
"guidelines": [\
"The report MUST be written in APA format",\
"Each sub section MUST include supporting sources using hyperlinks."\
],
"verbose": true
}
| Parameter | Description |
|---|---|
query |
The research question |
max_sections |
Maximum number of report sections |
max_revisions |
Maximum revision cycles per section |
publish_formats |
Output formats: markdown, pdf, docx |
include_human_feedback |
Whether to prompt for human input during research |
model |
LLM model to use |
follow_guidelines |
Whether to enforce the guidelines list |
Run the Research
python -m multi_agents_ag2.main
The pipeline runs through five stages: planning, data gathering and analysis, quality review and revision, writing, and publishing.