Skip to content

mkassaf/deepagents-tutorial

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 provider
export ANTHROPIC_API_KEY="your-anthropic-key"   # get at console.anthropic.com
# OR
export 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

# Example What it teaches Difficulty
01 Hello World Creating your first agent, basic tools ⭐ Beginner
02 Research Agent Web search, planning, file system ⭐⭐ Beginner+
03 Memory Agent Long-term memory across sessions ⭐⭐⭐ Intermediate
04 Subagents Team Multiple specialist agents, delegation ⭐⭐⭐ Intermediate
05 Streaming Agent Real-time token output, SSE streaming ⭐⭐ Beginner+
06 Human-in-the-Loop Agent pauses for human approval ⭐⭐⭐ Intermediate
07 FastAPI Server REST 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

Concept What it is Analogy
Agent The main AI brain A project manager
Tool A Python function the agent can call A tool in a toolbox
Planner write_todos built-in tool A to-do list
File system read/write files for large data A scratchpad
Subagent A specialized mini-agent A team member
Memory Persistent storage across sessions A 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

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages