Skip to content
intermediate 20 min

Deep Research Agent with Sub-Agents

Orchestrate multiple AI specialists to research any topic in depth

researchsubagentsweb-search

The Problem

Building a research agent that can break complex topics into sub-tasks, search the web, and synthesize findings requires coordinating multiple specialists — web searchers, analyzers, writers — while maintaining context across all of them.

The Solution

Deep Agents provides built-in sub-agent delegation via the `task` tool, web search integration, and automatic context management. Define specialist sub-agents, give them tools, and the orchestrator handles coordination, context isolation, and result aggregation.

Working Code

deep_research_agent.py
from deepagents import create_deep_agent
from langchain.chat_models import init_chat_model
from langchain_core.tools import tool
@tool
def web_search(query: str, max_results: int = 5) -> dict:
"""Search the web for current information."""
from tavily import TavilyClient
client = TavilyClient()
return client.search(query, max_results=max_results)
research_sub_agent = {
"name": "researcher",
"description": "Delegate research to a specialist sub-agent.",
"system_prompt": "You are a research specialist. Search thoroughly and synthesize findings.",
"tools": [web_search],
}
agent = create_deep_agent(
model=init_chat_model("anthropic:claude-sonnet-4-5-20250929"),
tools=[web_search],
system_prompt="You are a research orchestrator. Break complex topics into sub-tasks and delegate to researchers.",
subagents=[research_sub_agent],
)
result = agent.invoke({"messages": [("user", "Research the latest advances in AI agent architectures")]})

Step by Step

1

Install & configure

Install deepagents with `pip install deepagents` and set your API keys for Anthropic and Tavily (web search).

2

Define search tools

Create a `web_search` tool using Tavily that the agent and sub-agents can use to find current information on any topic.

3

Create sub-agents

Define specialist sub-agents as dictionaries with a name, description, system prompt, and tools. The orchestrator will delegate tasks to them automatically via the `task` tool.

4

Run the orchestrator

Invoke the agent with your research question. It will plan sub-tasks, delegate to researchers, collect results, and synthesize everything into a comprehensive answer.

Ready to build this?

Get started with Vstorm's open-source tools — production-tested, fully documented, and free.

Get Started

Ready to build your first production AI agent?

Open-source tools, battle-tested patterns, zero boilerplate. Configure your stack and ship in minutes — not months.