Build your first deep agent in minutes
This guide walks you through creating your first deep agent with planning, file system tools, and subagent capabilities. You'll build a research agent that can conduct research and write reports.
Before you begin, make sure you have an API key from a model provider (e.g., Anthropic, OpenAI).
```bash pip theme={null} pip install deepagents tavily-python ```uv add deepagents tavily-pythonpoetry add deepagents tavily-pythonexport ANTHROPIC_API_KEY="your-api-key"
export TAVILY_API_KEY="your-tavily-api-key"import os
from typing import Literal
from tavily import TavilyClient
from deepagents import create_deep_agent
tavily_client = TavilyClient(api_key=os.environ["TAVILY_API_KEY"])
def internet_search(
query: str,
max_results: int = 5,
topic: Literal["general", "news", "finance"] = "general",
include_raw_content: bool = False,
):
"""Run a web search"""
return tavily_client.search(
query,
max_results=max_results,
include_raw_content=include_raw_content,
topic=topic,
)# System prompt to steer the agent to be an expert researcher
research_instructions = """You are an expert researcher. Your job is to conduct thorough research and then write a polished report.
You have access to an internet search tool as your primary means of gathering information.
## `internet_search`
Use this to run an internet search for a given query. You can specify the max number of results to return, the topic, and whether raw content should be included.
"""
agent = create_deep_agent(
tools=[internet_search],
system_prompt=research_instructions
)result = agent.invoke({"messages": [{"role": "user", "content": "What is langgraph?"}]})
# Print the agent's response
print(result["messages"][-1].content)Your deep agent automatically:
- Planned its approach: Used the built-in
write_todostool to break down the research task - Conducted research: Called the
internet_searchtool to gather information - Managed context: Used file system tools (
write_file,read_file) to offload large search results - Spawned subagents (if needed): Delegated complex subtasks to specialized subagents
- Synthesized a report: Compiled findings into a coherent response
Now that you've built your first deep agent:
- Customize your agent: Learn about customization options, including custom system prompts, tools, and subagents.
- Understand middleware: Dive into the middleware architecture that powers deep agents.
- Add long-term memory: Enable persistent memory across conversations.
- Deploy to production: Learn about deployment options for LangGraph applications.
[Edit the source of this page on GitHub.](https://github.com/langchain-ai/docs/edit/main/src/oss/deepagents/quickstart.mdx) [Connect these docs programmatically](/use-these-docs) to Claude, VSCode, and more via MCP for real-time answers.
To find navigation and other pages in this documentation, fetch the llms.txt file at: https://docs.langchain.com/llms.txt