Understand Agent orchestration from first principles: State Graph + Nodes + Conditional Edges.
This is a hands-on, zero-to-production multi-agent systems course: using LangChain / LangGraph as the vehicle, it takes you from first principles of Agent orchestration (State Graph + Nodes + Conditional Edges) all the way to a full set of production-grade capabilities — persistent memory (checkpoint), human-in-the-loop (HITL), a traceable independent memory layer, MCP tool interfaces, multi-agent collaboration (A2A), service deployment, and observability. It is both a step-by-step learning path and a demonstrable production-grade multi-agent system reference implementation.
Positioning: This repo grew out of the official LangChain tutorials, re-engineered and extended — I used it to deeply understand LangGraph's state machine, checkpoint, and HITL internals, then filled the gaps the original tutorials miss (independent memory layer, MCP communication substrate, deployment & observability). If asked in an interview whether it was independently designed, be honest about this; focus on the internals you actually mastered. Its relationship with a self-built kernel project (e.g. "Lingxi") is complementary: one proves you can ship fast with frameworks, the other proves you can build the internals.
Our core thesis: most mainstream Agent frameworks (CrewAI, AutoGen, etc.) can be mapped onto LangGraph's model of StateGraph + Node + Conditional Edge. Master LangChain and LangGraph, and you master the underlying paradigm of Agent orchestration.
- This project is bilingual: Simplified Chinese (default) and English (under
/en/). - 本文档提供双语:简体中文(默认)与 English(
/en/)。
This repo ships an editor-agnostic Makefile that works in the PyCharm / WebStorm terminal, VS Code, or CI:
make setup # create .venv, install Python + Node deps, copy .env
make docs # build the bilingual docs site -> docs/.vitepress/dist
make docs-dev # live preview at http://localhost:5173
make run p=1 # run Phase 1 example (p=2..13 likewise; configure .env first — see "Configure the LLM" below)
make lint # py_compile all examplesTip — read the docs before coding (recommended): after
make setupinstalls the Node deps above, runmake docs-dev(ornpm run docs:dev) and open http://localhost:5173 in your browser to read the tutorials. The docs site explains each Phase's principles, code, and acceptance checklist in detail. We recommend reading the corresponding Phase chapter in order, then coming back tomake run p=Nto run the example — it works much better that way.
IDE usage (PyCharm + WebStorm): open the project root in PyCharm for the Python
examples/; opendocs/in WebStorm (or just runmake docs-devfrom the PyCharm terminal) for the docs site. Both IDEs have a built-in Terminal to run themakecommands above.Requirements: Python 3.13+, Node 22+.
Many readers see the long list of commands in this README and assume that finishing "Quick Start" means the project is done. It does not. The sections here fall into three categories — build this mental model first, then start:
1. Environment setup (one-time)
- Quick Start (one command): uses the
Makefileto install the Python + Node environment, copy.env, and tell you whichmakecommands exist. It only sets up the environment — it contains no learning content. - Configure the LLM (.env): the
.envcopied in the previous step defaults to local Ollama. You must change it to Ollama / DeepSeek / OpenAI based on your situation. This is a required config before running examples.
2. The actual learning content (core)
- Learning Path (13 Phases): walks through Agent orchestration (State Graph + Node + Conditional Edge) progressively from P1 to P13. P1–P9 are the fundamentals; P10/P11/P12/P13 are advanced hands-on chapters (independent memory layer / MCP tool interface / multi-agent collaboration A2A / A2A standard protocol). Each Phase comes with principle explanations, example code, and an acceptance checklist. This is the part you actually "learn".
3. Optional / maintainer-only (learners can skip)
- Running the Examples, Preview the Docs Locally: these are the manual equivalents of
make run p=Nandmake docs-dev(rawpip/python/npmcommands). If you usemake, you don't need them. - Deploy the Docs (GitHub Pages): publishes the site to the public web; only needed by repo maintainers.
Recommended learning order:
make setup # 1. set up the environment (one-time)
# then edit .env to choose your LLM (see "Configure the LLM")
make docs-dev # 2. open http://localhost:5173 and read Phase 1
make run p=1 # 3. run the Phase 1 example to verify understanding
# 4. repeat 2 -> 3 for P1 -> P13 until the whole project is done (P10/P11/P12/P13 are advanced — go deeper as needed)In one sentence: Quick Start = set up the tools; the 13 Phases = the course you actually study; Running Examples / Preview = how to use the tools; Deploy = publish the result. Finishing Quick Start is only the doorway.
⚠️ This step is required before running any example. Themake setupabove already copied.envfrom.env.example, but its default isLLM_PROVIDER=ollama— if you runmake runwithout starting local Ollama, you'll gethttpx.ConnectError: [Errno 61] Connection refused. Edit.env(e.g.nano .envor open it in your editor) using one of the two options below, then come back to run examples.
- Install Ollama: Homebrew
brew install ollama, or download the App from https://ollama.com. - Start the service: opening the Ollama App auto-starts it in the background; from the CLI use
ollama serve &. - Pull the models:
ollama pull qwen2.5:7b # chat model (Phases 1–9) ollama pull nomic-embed-text # embedding model (needed for the Phase 2 RAG chapter)
- Confirm in
.env:LLM_PROVIDER=ollama - Verify the service is up:
curl http://localhost:11434 # returns "Ollama is running" when OK
Edit .env, pick one:
# DeepSeek (cheap, reachable from China, recommended)
LLM_PROVIDER=deepseek
DEEPSEEK_API_KEY=your-key
# Qwen (Alibaba DashScope — fits "self-reliant / domestic models")
LLM_PROVIDER=qwen
QWEN_API_KEY=your-key
# or OpenAI
# LLM_PROVIDER=openai
# OPENAI_API_KEY=your-keyWith a cloud API you don't need to install/start Ollama — examples go straight through the official or compatible endpoint. After configuring
.envyou canmake run p=N.
The sections below are the manual equivalent steps.
| Phase | Topic |
|---|---|
| 1 | LangChain Core Concepts & Environment (with skippable primer) |
| 2 | Chains, Memory & RAG Basics |
| 3 | Agent Principles: from ReAct to Autonomous Loops |
| 4 | Tools & Function Calling |
| 5 | Multi-Agent Patterns & Framework Comparison |
| 6 | LangGraph Graph Orchestration Core |
| 7 | State, Memory & Human-in-the-loop |
| 8 | Production Deployment |
| 9 | Capstone Comprehensive Project & Full Review |
| 10 | Independent Memory Layer: episodic + semantic + traceability (anti-hallucination) |
| 11 | MCP Tool Interface: let Agents call standard-protocol tools |
| 12 | Multi-Agent Collaboration (A2A): native supervisor + worker agents |
| 13 | A2A Standard Protocol: Agent Card + JSON-RPC cross-process interop |
- Install dependencies:
python -m venv .venv && source .venv/bin/activate pip install -r requirements.txt
- Copy and configure the environment variables:
cp .env.example .env # edit .env and choose LLM_PROVIDER (openai / deepseek / qwen / ollama) - Run an example (Phase 1 as a sample):
python -m examples.p1.hello_chain
After configuring the LLM, run ./verify.sh to automatically execute Phase 10–13 and check each one against its key markers (it doesn't compare exact answers, since LLM output is non-deterministic):
./verify.sh # verify Phase 10 -> 13 in order
./verify.sh 11 # verify a single Phase
./verify.sh 10 13 # verify only the specified PhasesEach Phase makes a real LLM call, so it takes a while (default per-Phase timeout is 360s). Requires a usable
LLM_PROVIDERin.env.
npm install
npm run docs:dev # dev preview
npm run docs:build # build the static siteThe docs site is built and deployed to GitHub Pages automatically via GitHub Actions — no manual upload needed.
- In the repo, go to Settings → Pages → Source and select GitHub Actions (one-time setup).
- Pushing to the
mainbranch triggers the deployment:make deploy-docs # = npm run docs:build + git push origin main - Once deployed, the site is at:
https://shadowquill.github.io/langchain-langgraph-tutorial/
The deployment workflow is at
.github/workflows/deploy-docs.yml; thebaseindocs/.vitepress/config.tsis already set to the repo namelangchain-langgraph-tutorial, so no change is needed.
All examples switch models through one unified LLM Provider abstraction layer (examples/common/llm.py):
openai: official OpenAI (default), requiresOPENAI_API_KEY.deepseek: DeepSeek, OpenAI-compatible endpoint, requiresDEEPSEEK_API_KEY.qwen: Qwen (Alibaba DashScope, OpenAI-compatible endpoint), requiresQWEN_API_KEY— fits "self-reliant / domestic models".ollama: local Ollama, key-free, recommended for a zero-friction experience in the early chapters.
See .env.example and the docs for each Phase for details.
