examples/agent/deep_research_agent/README.md
This example shows a DeepResearch Agent implementation using the AgentScope framework. The DeepResearch Agent specializes in performing multi-step research to collect and integrate information from multiple sources, and generates comprehensive reports to solve complex tasks.
Set Environment Variable:
export DASHSCOPE_API_KEY="your_dashscope_api_key_here"
export TAVILY_API_KEY="your_tavily_api_key_here"
export AGENT_OPERATION_DIR="your_own_direction_here"
Test Tavily MCP Server:
npx -y tavily-mcp@latest
Run the script:
python main.py
If you want to have multi-turn conversations with the Deep Research Agent, you can modify the code as follows:
from agentscope.agent import UserAgent
user = UserAgent("User")
user_msg = None
msg = []
while True:
user_msg = await user(user_msg)
if user_msg.get_text_content() == "exit":
break
msg.append(user_msg)
assistant_msg = await agent(user_msg)
msg.append(assistant_msg)
The DeepResearch Agent only supports web search through the Tavily MCP client currently. To use this feature, you need to start the MCP server locally and establish a connection to it.
from agentscope.mcp import StdIOStatefulClient
tavily_search_client= StdIOStatefulClient(
name="tavily_mcp",
command="npx",
args=["-y", "tavily-mcp@latest"],
env={"TAVILY_API_KEY": os.getenv("TAVILY_API_KEY", "")},
)
await tavily_search_client.connect()
Note: The example is built with DashScope chat model. If you want to change the model in this example, don't forget to change the formatter at the same time! The corresponding relationship between built-in models and formatters are list in our tutorial