How to build your first
deep agent
A practical guide to LangChain's Deep Agents framework,
with lessons from a Senior AI Engineer.

After two years of developing advanced AI agents, I've started using LangChain's Deep Agents framework - and it's changed how I think about building autonomous AI systems. This guide covers everything I've learnt about the framework, building up from a simple agent to something genuinely powerful.
We'll build a meeting prep assistant - an agent that researches the people you're about to meet and prepares a briefing document. It's a practical example that showcases what makes deep agents different from simpler approaches.
I was genuinely surprised by how quick it is to get started - with just a few lines of code - but we'll layer on capabilities step by step so you can see how each feature adds value.
By the end, you'll understand not just how to use Deep Agents, but why it's designed the way it is.
Why 'shallow' agents aren't enough
Let me show you what I mean by a "shallow" agent. Here's the kind of meeting prep agent you might build with a typical agent framework:
This works fine - until it doesn't. What if the person isn't on LinkedIn? What if the meeting is internal and you don't need company research? What if you find conflicting information and need to dig deeper? The workflow can't adapt for these situations.
Deep agents are different. They can plan their approach, decide what to investigate based on what they find, and adapt when things don't go as expected. Here's what makes them work:
- Planning tools - a todo list that helps the agent track progress across long tasks
- Sub-agent delegation - the ability to create specialised agents for specific subtasks
- Filesystem access - a workspace where agents can store notes and accumulated context
- Automatic context management - summarises conversation history when it gets too long
These might sound simple, but the combination is surprisingly effective. Let's build up our meeting prep agent step by step, adding each capability and seeing how it improves the result.
When to use LangGraph vs Deep Agents
If you've used LangChain before, you might be wondering how Deep Agents fits alongside LangGraph. Both were created by the same company, but they serve different purposes.
LangGraph gives you complete control over your AI agent and how it should approach a task. You can define the nodes, edges, and state transitions manually. This is really useful when you need to develop custom, repeatable workflows.
For example, an ordering system where each step - payment, inventory check, shipping - requires a specific state change and support for rollback.
Deep Agents is much more flexible. It allows you to create an agent that can plan, use tools, delegate to sub-agents, and manage its own context. It's well-suited for longer, more complex tasks and when you can't predict the exact workflow of your users.
For example, a research assistant that searches the web, decides what to investigate next based on what it finds, and can dig deeper if it doesn't have enough information - without you having to define every step in advance.
Generally, I'd advise that you start with Deep Agents. If you find you need greater control over the process and what tools the agent calls, you should use LangGraph instead. But most agent use cases - research, coding assistants, data analysis - are a natural fit for Deep Agents.
1. Create a basic meeting agent
Let's start with the simplest possible deep agent. First, install the package:
Then create a .env file with your API keys:
For web search, we'll use Tavily - it's free and works great with AI agents.. Navigate to tavily.com, create an account, and copy the the API key.
We'll now create a basic agent, which can search the web and help us prepare for upcoming meetings.
Even this basic version is more capable than the shallow agent we saw earlier. The agent can decide what to search for, change its approach if it doesn't find what it needs, and combine information from multiple searches.
2. Add planning capabilities
The basic agent works fine, but it will struggle with complex, long-running tasks - the agent can jump between topics randomly, forget what it's already searched for, or miss important areas entirely.
By using the built-in planning tools, we can keep our AI agent on-track when it's faced with difficult work. The agent will write todos, track what it needs to research, and then mark them complete as it progresses.
The planning tools (write_todos and read_todos) are automatically available - you just need to tell the agent to use them in the system prompt.
This might seem trivial - it's just a todo list. But I was surprised by how much it improves the agent's behaviour. When the agent explicitly writes down what it's trying to do, it stays more focused and makes better decisions about what to do next.
3. Use file storage for longer research
When the agent researches multiple people or a complex topic, it accumulates a lot of context. Search results, company profiles, news articles - it all adds up. Eventually, you'll hit the model's context limit.
Deep Agents solves this with filesystem tools. The agent can save research notes to files as it goes, keeping its "working memory" focused on the current task.
The filesystem tools (write_file, read_file, ls) are built-in, just like the planning tools. The agent can create directories, write notes, and read them back when needed.
There's also automatic context management happening behind the scenes. When the conversation exceeds about 170,000 tokens, the framework automatically summarises earlier parts to make room for new content.
4. Add sub-agents for specialisation
For our meeting prep agent, we're doing two different things: deep research and writing a briefing document. These require different approaches - research needs to be thorough and exploratory, while the briefing needs to be concise and actionable.
Sub-agents let us split these into specialised roles. The key benefit isn't just separation of concerns - it's context isolation. All the intermediate search results stay in the research sub-agent's context. The main agent only sees the final summary.
Now when the main agent delegates research, all those search results and intermediate steps stay in the researcher's context. The main agent only sees the final summary, keeping its context clean and focused.
5. Add custom tools
Web search is useful, but our meeting prep agent could be much more effective with access to internal systems. Let's add tools to check our CRM for past interactions and look up calendar availability.
The @tool decorator tells the framework how to present each function to the AI. The docstring becomes the tool's description, so write it clearly - this helps the agent understand when to use each tool.
6. Add memory for repeat meetings
You meet with some people regularly - quarterly business reviews, ongoing client relationships, recurring team syncs. It would be wasteful to re-research them from scratch every time.
Deep Agents supports persistent storage, so the agent can remember past research and build on it.
Now the agent will check for existing information before doing new research. For a recurring client, it might say "I last prepared a briefing for Sarah Chen three months ago. Since then, DataFlow announced a Series B funding round. Let me update the briefing with this new information."
7. Require approval before sending
Our meeting prep agent can now send briefings via email. But you probably don't want it sending emails without your approval - what if the research contains something sensitive or incorrect?
Deep Agents has built-in support for human-in-the-loop workflows. You can require approval for specific tools before they execute.
Now when the agent tries to send an email, execution pauses and you'll be asked to approve it. You can approve as-is, edit the content first, or reject it entirely.
Key takeaways
After building our meeting prep agent step by step, here's what I've learnt about deep agents:
1. Deep agents adapt, shallow agents don't
The shallow meeting prep agent we started with followed a fixed workflow. The deep agent we built can adapt its research based on what it finds, dig deeper when needed, and handle edge cases gracefully. That flexibility is the core difference.
2. Planning tools make a bigger difference than you'd expect
When I first saw that Deep Agents uses a todo list for planning, I thought it was trivial. But forcing the agent to explicitly write down its plan makes a huge difference. Our meeting prep agent stays focused and methodical instead of jumping around randomly.
3. Sub-agents are about context isolation
The research sub-agent can accumulate pages of search results without cluttering the main agent's context. The main agent only sees the final summary. This is crucial for longer tasks like thorough meeting preparation.
4. Build incrementally
We started with just web search and gradually added planning, file storage, sub-agents, custom tools, memory, and approval workflows. Each capability built on the last. Don't try to build a sophisticated system from scratch.
5. Write clear tool descriptions
The quality of your tool docstrings directly affects how well the agent uses them. Be specific about what each tool does and when to use it. Vague descriptions lead to vague behaviour.
Summary
We started with a shallow meeting prep agent that followed a fixed workflow and couldn't adapt. By the end, we had a deep agent that can plan its research, store context in files, delegate to specialised sub-agents, integrate with internal systems, remember past meetings, and require approval before taking action.
That progression - from simple to sophisticated, each step adding clear value - is how I'd recommend approaching any deep agent project. Don't try to build everything at once. Start with basic tools, then add capabilities as you hit their limits.
The meeting prep example is just one application. The same patterns work for research assistants, coding helpers, data analysis, customer support - anywhere you need an agent that can handle complex, unpredictable tasks rather than following a fixed script.

Read by executives at:

Loop