LangGraph 1.0 Tutorial
$ npx -y skills add luochang212/dive-into-langgraph --agent claude-code
Run the curl in your terminal, the rest in Claude Code.
What's inside
中文 | English
本教程已转为 Agent Skill。现在无需使用人脑学习本教程,只需要为你的 Claude Code 安装本 Skill,即可写出高质量的 LangChain 和 LangGraph 代码。详见:SKILL.md
使用 npx 安装本 Skill (dive-into-langgraph):
npx skills add luochang212/dive-into-langgraph
2025 年 10 月中旬,LangGraph 发布 1.0 版本。开发团队承诺这是一个稳定版本,预计未来接口不会大改,因此现在正是学习它的好时机。
这是一个开源电子书项目,旨在帮助 Agent 开发者快速掌握 LangGraph 框架。LangGraph 是由 LangChain 团队开发的开源智能体框架。它功能强大,你要的记忆、MCP、护栏、状态管理、多智能体它全都有。LangGraph 通常与 LangChain 一起使用:LangChain 提供基础组件和工具,LangGraph 负责工作流和状态管理。因此,两个库都需要学习。为了让大家快速入门,本教程将两个库的主要功能提取出来,分成 14 个章节进行介绍。
pip install -r requirements.txt
以下为 requirements.txt 中的依赖包清单:
pydantic
python-dotenv
rank-bm25
langchain[openai]
langchain-community
langchain-mcp-adapters
langchain-text-splitters
langgraph
langgraph-cli[inmem]
langgraph-supervisor
langgraph-checkpoint-sqlite
langgraph-checkpoint-redis
langmem
ipynbname
fastmcp
bs4
scikit-learn
supervisor
jieba
dashscope
tavily-python
ddgs
deepagents
本教程的内容速览:
| 序号 | 章节 | 主要内容 |
|---|---|---|
| 1 | 快速入门 | 创建你的第一个 ReAct Agent |
| 2 | 状态图 | 使用 StateGraph 创建工作流 |
| 3 | 中间件 | 使用自定义中间件实现四个功能:预算控制、消息截断、敏感词过滤、PII 检测 |
| 4 | 人机交互 | 使用内置的 HITL 中间件实现人机交互 |
| 5 | 记忆 | 创建短期记忆、长期记忆 |
| 6 | 上下文工程 | 使用 State、Store、Runtime 管理上下文 |
| 7 | MCP Server | 创建 MCP Server 并接入 LangGraph |
| 8 | 监督者模式 | 两种方法实现监督者模式:tool-calling、langgraph-supervisor |
| 9 | 并行 | 如何实现并发:节点并发、@task 装饰器、Map-reduce、Sub-graphs |
| 10 | RAG | 三种方式实现 RAG:向量检索、关键词检索、混合检索 |
| 11 | 网络搜索 | 实现联网搜索:DashScope、Tavily 和 DDGS |
| 12 | Deep Agents | 简单介绍 Deep Agents |
| 13 | Gradio APP | 基于 Gradio 开发流式对话智能体应用 |
| 14 | 附录:调试页面 | 介绍 langgraph-cli 提供的调试页面 |
[!NOTE]
承诺:本教程完全基于 LangGraph v1.0 编写,不含任何 v0.6 的历史残留。
langgraph-cli 提供了一个可快速启动的调试页面。
langgraph dev
详见:附录
第 13 章 开源了一个基于 Gradio + LangChain 实现的智能体应用,效果如下。你可以为这个应用添加更多功能,定制专属于你的智能体。

详见:/app
官方文档:
官方教程:
我们欢迎任何形式的贡献!
本作品采用 知识共享署名-非商业性使用-相同方式共享 4.0 国际许可协议 进行许可。
.env.example
.github/
workflows/
ci.yml
deploy-book.yml
.gitignore
.ruff.toml
1.quickstart.ipynb
10.rag.ipynb
11.web_search.ipynb
12.deep_agents.ipynb
13.gradio_app.ipynb
14.langgraph_cli.ipynb
2.stategraph.ipynb
3.middleware.ipynb
4.human_in_the_loop.ipynb
5.memory.ipynb
6.context.ipynb
7.mcp_server.ipynb
8.supervisor.ipynb
9.parallelization.ipynb
AGENTS.md
app/
.dockerignore
.env.example
.python-version
app.py
config/
__init__.py
mcp_config.py
docker-compose.yml
docker.conf
Dockerfile
docs/
ollama.md
query.md
README-en.md
images/
ai.png
gradio_app_raw.png
gradio_app.png
gradio_app.webp
user.png
logs/
.gitkeep
mcp/
code_execution.py
mcp-server-chart/
README.md
prompts/
__init__.py
middleware_todolist.py
prompt_base.py
prompt_enhance.py
subagent_search.py
pyproject.toml
README.md
requirements.txt
space/
.gitkeep
food.md
tests/
.gitkeep
test_agent_service.py
test_app_response.py
test_device_info.py
test_docs.py
test_role_play.py
test_web_ui.py
tools/
__init__.py
tool_fs.py
tool_math.py
tool_role.py
tool_runtime.py
tool_sci.py
tool_search.py
utils/
__init__.py
device_info.py
fix_dashscope.py
fix_deepseek.py
remove_html.py
think_view.py
tool_view.py
web_ui.py
uv.lock
book/
home.ipynb
README.md
create_references.sh
docs/
README-en.md
rule_horror.md
examples/
.env.example
docker-compose.yml
langmem.py
rag.py
redis.conf
router.py
store.py
time_travel.py
img/
case/
amap-maps.png
code-execution.png
role-play.png
favicon.ico
home.jpg
home.webp
langgraph-cli.png
overview-history.png
overview.png
social-preview.jpg
social-preview.webp
langgraph.json
LICENSE
mcp_server/
get_weather_mcp/
__init__.py
__main__.py
README.md
server.py
math_mcp/
__init__.py
__main__.py
README.md
server.py
mcp_supervisor.conf
README.md
myst.yml
pyproject.toml
README.md
requirements.txt
scripts/
check_notebooks.py
simple_agent.py
skills/
dive-into-langgraph/
references/
1.quickstart.md
10.rag.md
11.web_search.md
2.stategraph.md
3.middleware.md
4.human_in_the_loop.md
5.memory.md
6.context.md
7.mcp_server.md
8.supervisor.md
9.parallelization.md
scripts/
examples.py
tools/
__init__.py
tool_math.py
utils.py
SKILL.md
uv.lockFAQ
dive-into-langgraph is a Claude Code plugin with 1 hand-picked skill for documentation work, indexed on Flowy. Install it with the command on its page. It includes dive-into-langgraph. Its skills do not fire on their own yet. Request auto-invocation to have Flowy route them as you prompt. Free and open source.