---
source_url: "https://docs.langchain.com/oss/python/deepagents/deep-research?utm_source=openai"
title: Build a deep research agent - Docs by LangChain
mirrored_at: 2026-08-11T01:39:27.863Z
host: docs.langchain.com
cited_in_42a: true
mirror_canonical: "https://index.42a.ai/docs.langchain.com/oss/python/deepagents/deep-research__q__utm_source_openai"
---

> **Original source:** https://docs.langchain.com/oss/python/deepagents/deep-research?utm_source=openai

## Overview

This guide demonstrates how to build a multi-step web research agent from scratch using [Deep Agents](https://docs.langchain.com/oss/python/deepagents). 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 the opt-in todo list middleware
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:

-   [Subagents](https://docs.langchain.com/oss/python/deepagents/subagents) for parallel, context-isolated research
-   Custom [tools](https://docs.langchain.com/oss/python/langchain/tools) for web search
-   Multi-step planning with the opt-in [planning tool](https://docs.langchain.com/oss/python/deepagents/overview#task-planning)

## Prerequisites

API keys for:

-   Anthropic (Claude) or Google (Gemini)
-   [Tavily](https://www.tavily.com/) for web search (optional - free tier sufficient)
-   [LangSmith](https://smith.langchain.com/?utm_source=docs&utm_medium=cta&utm_campaign=langsmith-signup&utm_content=oss-deepagents-deep-research) for tracing (optional)

## Setup

1

2

3

Create `agent.py` in your project directory:

1

2

3

4

## 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 synchronously
    
-   Stream updates
    

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](https://docs.langchain.com/langsmith/observability) to debug and monitor multi-step behavior.

## Full code

View the complete [Deep Research example](https://github.com/langchain-ai/deepagents/tree/main/examples/deep_research) 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](https://docs.langchain.com/oss/python/deepagents/subagents): Learn how to configure subagents with different tools and prompts
-   [Customization](https://docs.langchain.com/oss/python/deepagents/customization): Customize models, tools, system prompts, and optional [task planning](https://docs.langchain.com/oss/python/deepagents/overview#task-planning)
-   [LangSmith](https://docs.langchain.com/langsmith/observability): Trace research runs and debug multi-step behavior
-   [Deep Research Course](https://academy.langchain.com/courses/deep-research-with-langgraph): Full course on deep research with LangGraph

* * *