Skip to main content
This guide walks you through creating your first deep agent with the Deep Agents SDK. Use the SDK for maximum flexibility and host agents yourself or run a custom LangSmith Deployment. To run agents in production without having to manage infrastructure, see the Managed Deep Agents quickstart instead. You will build a research agent that can conduct research and write reports.

Build the Deep Agents research quickstart

Using an AI coding assistant?
  • Install the LangChain Docs MCP servers to give your agent access to up-to-date LangChain documentation and examples.

    Connect LangChain docs MCP servers

  • Install LangChain Skills to improve your agent’s performance on LangChain ecosystem tasks.

    Install LangChain Skills

Prerequisites

Before you begin, make sure you have an API key from a model provider (e.g., Gemini, Anthropic, OpenAI).
Deep Agents require a model that supports tool calling. See customization for how to configure your model.

Step 1: Install dependencies

Google, OpenAI, and Anthropic all provide built-in web search tools: no extra package or API key required. If you use a different provider or prefer Tavily for search, install the Tavily package as well:

Step 2: Set up your API keys

If you are using the LangSmith LLM Gateway, traffic to providers is routed through LangSmith. Use the gateway key as the API key instead.

Step 3: Create a search tool

Google, OpenAI, and Anthropic offer built-in web search tools that run server-side: no extra package or API key needed. Pass a provider tool dict directly to create_deep_agent.

Step 4: Create a deep agent

Pass your search tool and model to create_deep_agent. Pass a model string in provider:model format, or an initialized model instance. See supported models for all providers and suggested models for tested recommendations.

Step 5: Set up LangSmith tracing

In an agent-based workspace, create an agent once before sending traces. Use agent addressing to select its identifier and environment. If an integration requires project_name, use the selected environment’s tracer_session_name as a compatibility value.
LangSmith provides you with visibility into your agent’s execution, allowing you to view tool calls, subagent delegation, and LLM responses. Sign up at smith.langchain.com, create an API key, and set these environment variables:

Step 6: Run the agent

How does it work?

Your deep agent automatically:
  1. Conducts research by calling the internet_search tool to gather information.
  2. Manages context by using file system tools (write_file, read_file) to offload large search results.
  3. Spawns subagents as needed to delegate complex subtasks to specialized subagents.
  4. Synthesizes a report to compile findings into a coherent response.
To add structured task planning with write_todos, opt in with TodoListMiddleware. See Task planning.

Examples

For examples of agents and patterns you can build with Deep Agents, see Examples.

Streaming

Deep Agents have built-in streaming for real-time updates from agent execution using LangGraph. This allows you to observe output progressively and review and debug agent and subagent work, such as tool calls, tool results, and LLM responses.

Next steps

Now that you’ve built your first deep agent:
  • Customize your agent: Learn about customization options, including custom system prompts, tools, and subagents.
  • Add long-term memory: Enable persistent memory across conversations.
  • Deploy to production: Use Managed Deep Agents to create, run, and operate deep agents in LangSmith.
  • Test and evaluate: Use LangSmith evaluation to run automated tests and measure your agent’s performance against a dataset.