Skip to main content

Overview

This guide demonstrates how to build a multi-step web research agent from scratch using Deep Agents. The agent decomposes research questions into focused tasks, delegates them to specialized sub-agents, and synthesizes findings into a comprehensive report. The agent you build will:
  1. Plan research using a todo list
  2. Delegate focused research tasks to sub-agents with isolated context
  3. Assess search results and plan next steps as you gather information
  4. Synthesize findings with proper citations into a final report
The spawned sub-agents will conduct web searches with Tavily, fetching full webpage content for analysis.

Key concepts

This tutorial covers:

Prerequisites

API keys for:
  • Anthropic (Claude) or Google (Gemini)
  • Tavily for web search (optional - free tier sufficient)
  • LangSmith for tracing (optional)

Setup

1

Create project directory

2

Install dependencies

3

Set API keys

Build the agent

Create agent.py in your project directory:
1

Add tools

Add the custom search tool. The tavily_search tool uses Tavily for URL discovery, then fetches full webpage content so the agent can analyze complete sources instead of summaries.
2

Add prompts

Add the orchestrator workflow and sub-agent prompt templates to agent.py:
3

Create the agent

Add the model initialization and agent creation to agent.py. Choose your provider:

Run the agent

You can run the agent synchronously, meaning it will wait for the full result and then print it, or you can stream updates as they come in. Add the code from the respective tab at the bottom of agent.py:
Run the agent from the project root:
If you set the LANGSMITH_API_KEY environment variable before running, you can view the agent’s traces in LangSmith to debug and monitor multi-step behavior.

Full code

View the complete Deep Research example on GitHub.

Next steps

Now that you’ve built the agent, customize it by changing the prompt constants in your agent file to adjust the workflow, delegation strategy, or researcher behavior. You can also tune the delegation limits to allow for more parallel sub-agents or delegation rounds. For more information on the concepts in this tutorial, check out the following resources:
  • Subagents: Learn how to configure subagents with different tools and prompts
  • Customization: Customize models, tools, system prompts, and planning behavior
  • LangSmith: Trace research runs and debug multi-step behavior
  • Deep Research Course: Full course on deep research with LangGraph