Skip to content

Repository files navigation

🤖 Deep Agents Tutorial

A beginner-friendly guide to building AI agents with LangChain's Deep Agents framework.

Deep Agents make it easy to create LLM-powered assistants that can plan, use tools, delegate to subagents, and remember things across conversations.


📁 Repository Structure

deepagents-tutorial/
│
├── 01_hello_world/ # Start here! Simplest possible agent
├── 02_research_agent/ # Agent that searches the web and writes reports
├── 03_memory_agent/ # Agent that remembers users across conversations
├── 04_subagents_team/ # Team of specialist agents working together
├── 05_streaming/ # Real-time token output with agent.stream()
├── 06_human_in_loop/ # Agent pauses for human approval on sensitive actions
├── 07_fastapi_server/ # Full REST API server with streaming + sessions
│
├── requirements.txt # All Python dependencies
└── README.md # You are here

🚀 Quick Start

1. Clone this repo

git clone https://github.com/mkassaf/deepagents-tutorial.git
cd deepagents-tutorial

2. Install dependencies

pip install -r requirements.txt

3. Set your API keys

# Required: pick one LLM providerexport ANTHROPIC_API_KEY="your-anthropic-key"# get at console.anthropic.com# ORexport OPENAI_API_KEY="your-openai-key"# get at platform.openai.com# Required for examples 02 and 04 (web search)export TAVILY_API_KEY="your-tavily-key"# free tier at tavily.com

4. Run an example

# Start with the simplest one
python 01_hello_world/agent.py

📚 Examples Overview

#ExampleWhat it teachesDifficulty
01Hello WorldCreating your first agent, basic tools⭐ Beginner
02Research AgentWeb search, planning, file system⭐⭐ Beginner+
03Memory AgentLong-term memory across sessions⭐⭐⭐ Intermediate
04Subagents TeamMultiple specialist agents, delegation⭐⭐⭐ Intermediate
05Streaming AgentReal-time token output, SSE streaming⭐⭐ Beginner+
06Human-in-the-LoopAgent pauses for human approval⭐⭐⭐ Intermediate
07FastAPI ServerREST API, multi-session, production deploy⭐⭐⭐ Intermediate

🧠 How Deep Agents Work (Big Picture)

User asks a question
↓
Deep Agent (brain)
├── Plans steps with write_todos
├── Reads/writes files to manage context
├── Calls your custom tools (search, APIs...)
└── Spawns subagents for complex subtasks
↓
Final answer returned to user

The key insight: unlike a simple chatbot, a Deep Agent actively manages its own workflow. It decides what to do next, tracks progress, and handles errors — just like a human assistant would.


🔑 Key Concepts

ConceptWhat it isAnalogy
AgentThe main AI brainA project manager
ToolA Python function the agent can callA tool in a toolbox
Plannerwrite_todos built-in toolA to-do list
File systemread/write files for large dataA scratchpad
SubagentA specialized mini-agentA team member
MemoryPersistent storage across sessionsA notebook

📦 Dependencies


📖 Further Reading


🤝 Contributing

Found a bug or want to add an example? Open an issue or PR!


Built with ❤️ using LangChain Deep Agents

About

A beginner-friendly tutorial for LangChain Deep Agents with 4 detailed examples

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages