08F.4 The LangChain Ecosystem and Your Setup
Lesson 08F.1 surveyed the whole agent-framework field and built one support agent four ways, and one of those ways used LangGraph. This lesson starts the module's deep dive into the two libraries that most agent code in the Python world ends up touching: LangChain and LangGraph. Before you write any real code with them (that starts in 08F.5), you need the map. "LangChain" is not one thing: it is a company, a family of Python packages, a hosted platform, a deployment server and, more recently, a harness for long-running agents, and the names have changed several times. Tutorials from 2023 and 2024 describe an API that no longer exists. This lesson explains what each product is, which package holds what, what changed between 0.x and 1.x and how to read old code, how to set up a project with uv that works the first time, and how to decide between LangChain, LangGraph, both or neither.
What you'll learn
- What LangChain, LangGraph, LangSmith, Deep Agents and LangGraph Server (now called LangSmith Agent Server) each are, in which layer of the stack they sit, and how they depend on each other
- The history from 2022 to 2026 and why the API kept changing, so that you can date any tutorial you find
- The package map:
langchain-core,langchain,langchain-classic, partner packages such aslangchain-openai, the sunsetlangchain-community, the LangGraph family,langsmithanddeepagents, and whatuv add langchainactually installs - The version policy: semantic versioning, the long-term-support commitment for 1.0, the stability labels and how fast the packages really move
- The v0 to v1 migration: what moved where, how old imports fail, the two different functions both called
create_react_agent, and a step-by-step migration checklist - Project setup with
uv: Python version, extras, provider packages, environment variables, a keyless smoke test and the failures you are most likely to hit - A survey of Deep Agents and Agent Server (packages, licences, hosting, when to use them)
- How to choose: LangChain, LangGraph, both, Deep Agents, or neither
What you don't need
- Any LangChain experience. Every term is introduced from zero, and the legacy patterns are explained only so you can recognize them.
- An API key. Parts 1 to 4, 6 and 7 are reading. Part 5 has a keyless path that you can run: a real LangGraph graph, a fake chat model and a real
create_agentagent, all without a provider. - The agent loop from scratch. 08A.2 built it, and this lesson assumes you have seen it.
Setup
You need Python 3.11 or newer (see 5.1 for why) and uv. If you have not set up uv before, lesson 03.1, Part 4 walks through it. The short version:
uv init langchain-lab --bare --python 3.13 && cd langchain-lab # once per project
uv add langchain langgraph python-dotenv
uv add langchain-openai langchain-anthropic langchain-google-genai # only the providers you use (langchain-google-genai is optional)
# or: pip install langchain langgraph python-dotenv langchain-openai langchain-anthropic langchain-google-genaiThe keys, if you have them, go in the same .env file as in Modules 03 and 08A. This lesson never prints a key value.
# .env (never commit this file)
OPENAI_API_KEY=...
ANTHROPIC_API_KEY=...
GEMINI_API_KEY=... # optional
OPENROUTER_API_KEY=... # optional gatewayVersions (current at time of writing, read from PyPI on 14 November 2026; they move several times a week, so treat them as a snapshot): langchain 1.5.0, langchain-core 1.8.0, langgraph 1.2.22, langgraph-prebuilt 1.1.2, langgraph-checkpoint 4.3.2, langchain-classic 1.0.8, langchain-openai 1.8.0, langchain-anthropic 1.7.10, langchain-google-genai 4.5.0, langchain-openrouter 0.2.9, langchain-community 0.4.2 (sunset, last release), langchain-text-splitters 1.1.3, langsmith 0.14.17, deepagents 0.7.38 and uv 0.13.8. The samples in Part 5 that show real output were run on 14 November 2026 against exactly these versions.
What you must be able to do after this lesson#
- Place LangChain, LangGraph, LangSmith and Deep Agents in the stack
- Date an old tutorial using the version history and package map
- Set up a project with uv and run a keyless smoke test
- Read legacy imports and say where the code moved in v1
- Choose between LangChain, LangGraph, both, Deep Agents or neither
Why this matters for an AI engineer#
| You'll hear... | You'll understand it after... |
|---|---|
| "What is the difference between LangChain, LangGraph and LangSmith?" | Part 1 |
| "LangChain is dead, everyone uses LangGraph now." | 1.2, Part 2 and 7.3 |
| "Is LangGraph Server the same as LangSmith Deployment?" | 1.7 The naming map and 6.2 |
| "Is Deep Agents a replacement for LangChain?" | 1.5 and 6.1 |
"Do I install langchain or langchain-openai?" |
3.2 and 3.5 |
"This tutorial does from langchain.chains import LLMChain and it crashes." |
Part 4 |
"Should I use langchain-community or langchain-classic?" |
3.7 and 3.8 |
| "Which Python version do I need?" | 5.1 |
| "We upgraded and the agent broke." | 2.4 version policy and 5.10 |
| "Do we need LangSmith?" | 1.4 and 5.7 |
| "Do we use LangChain for the support bot, or just the OpenAI SDK?" | Part 7 |
Part 1: The stack in one picture#
1.1 Framework, runtime, harness, platform#
The LangChain documentation itself draws the map with four words, and they are the clearest way to keep the products apart. Its formula is Agent = Model + Harness: the model reasons, and the harness is everything around the model (the loop, the tools, the context handling, the prompts, the memory).
| Product | Layer | What the official docs say it is | PyPI package |
|---|---|---|---|
| LangChain | Agent framework | Abstractions such as standard message content blocks, the agent loop and middleware. create_agent is "a minimal, highly configurable agent harness". |
langchain (plus langchain-core) |
| LangGraph | Agent runtime | "A low-level orchestration framework and runtime for building, managing, and deploying long-running, stateful agents": durable execution, streaming, human-in-the-loop, persistence. It does not prescribe prompts or agent architecture. | langgraph |
| Deep Agents | Agent harness | Opinionated and batteries-included: planning, subagents, a virtual filesystem and context management on top of LangChain and LangGraph. | deepagents |
| LangSmith | Platform | Tracing, evaluation, prompts and deployment, across frameworks. | langsmith (the SDK) plus a hosted or self-hosted service |
| LangSmith Agent Server (formerly LangGraph Server, then LangSmith Deployment) | Deployment runtime | A workflow-orchestration runtime for agent workloads, exposing assistants, threads and runs over HTTP. | langgraph-api, langgraph-cli, langgraph-sdk |
LangChain's create_agent is a minimal harness inside a framework (you add the tools, prompts and middleware); Deep Agents is the opinionated harness that ships those pieces already chosen.
Three statements from the official docs (the "products" page and the LangGraph overview) carry most of the architecture, and they are worth reading as a unit:
- "For example, LangChain 1.0 is built on top of LangGraph." (products page)
- "While LangChain is built on top of LangGraph, you don't need to know LangGraph to use LangChain." (products page)
- "LangGraph does not require LangChain." (LangGraph overview)
Precisely: langgraph does not need the langchain package, but it does depend on langchain-core for messages and the Runnable interface, so installing it brings langchain-core (and, through it, langsmith) along. The independence is from the framework, not from the shared vocabulary.
So the dependency arrows run one way: Deep Agents sits on LangChain, LangChain sits on LangGraph, and both lean on langchain-core for the shared vocabulary of messages, tools and models. LangSmith sits beside the stack, watching it and (optionally) hosting it. Here it is as a picture:
flowchart TD
app["Your application"] --> choice{"How much do you want<br/>decided for you?"}
choice -->|"most of it"| da["Deep Agents<br/>(harness: planning, files, subagents)"]
choice -->|"a standard agent loop"| lc["LangChain<br/>(framework: create_agent, middleware, models, tools)"]
choice -->|"explicit control of state and flow"| lg["LangGraph<br/>(runtime: StateGraph, checkpoints, interrupts)"]
da -->|"built on"| lc
lc -->|"built on"| lg
lg --> core["langchain-core<br/>(messages, Runnables, tool and model interfaces)"]
lc --> core
lc -.->|"provider packages"| prov["langchain-openai, langchain-anthropic,<br/>langchain-google-genai, ..."]
app -.->|"traces, evals, prompts"| ls["LangSmith<br/>(platform)"]
lg -.->|"deploy as an API"| srv["Agent Server<br/>(assistants, threads, runs)"]
ls --- srvThe docs also place the products among their competitors, which is useful context when you read 08F.1: runtime alternatives to LangGraph are Temporal and Inngest; framework alternatives to LangChain include the Vercel AI SDK, CrewAI, the OpenAI Agents SDK, Google ADK and LlamaIndex; harness alternatives to Deep Agents include the Claude Agent SDK. (Lesson 08F.1 already compared those four ways, so this lesson does not repeat the comparison.)
1.2 LangChain: the framework#
LangChain (package langchain) is the part most people mean. In version 1.x its job is deliberately narrow, and you can read the whole public surface in one table (verified by inspecting the 1.5.0 package):
| Import | What it gives you | Lesson |
|---|---|---|
langchain.chat_models |
init_chat_model (one function for "give me a chat model from any provider") and the BaseChatModel base class |
08F.5 |
langchain.messages |
Message types (HumanMessage, AIMessage, ToolMessage...), standard content blocks and trim_messages |
08F.5 |
langchain.tools |
The @tool decorator and BaseTool |
08F.8 |
langchain.agents |
create_agent (the agent loop) and AgentState |
08F.8 |
langchain.agents.middleware |
Hooks that wrap the loop: summarization, human approval, model fallback, PII handling, call limits, retries and more | 08F.8 |
langchain.embeddings |
init_embeddings and the Embeddings base class |
08F.9 |
langchain.rate_limiters |
Rate limiters for model calls | 08F.5 |
langchain.mcp (beta) |
Built-in Model Context Protocol client support, installed with langchain[mcp] |
08F.8 |
Everything else you may have seen in a 2023 tutorial (chains, retrievers, memory classes, text splitters, vector stores, the hub) is either in langchain-core, in a dedicated package, in a provider package or in the legacy package langchain-classic. Part 3 says which.
The official description of what create_agent returns matters later in this lesson: it returns a compiled LangGraph graph. You will prove that yourself in 5.5. That is what "built on LangGraph" means in practice: every LangChain agent already has checkpointing, streaming and interrupts available, because the loop is a graph.
1.3 LangGraph: the runtime#
LangGraph (package langgraph) is lower level. You describe your program as a graph: a typed state object, nodes (plain Python functions that read the state and return updates) and edges (which node runs next, possibly chosen at run time). LangGraph then runs it, and gives you the properties that are hard to build yourself:
- Durable execution: a run can stop (crash, deploy, wait for a human) and resume from the last checkpoint.
- Persistence: state is saved by a pluggable checkpointer, and a thread of conversation can be continued days later.
- Human-in-the-loop: a node can pause the run with
interruptand be resumed with a decision. - Streaming: partial state, tokens and custom events as the graph runs.
LangGraph does not require LangChain, and its nodes do not have to call a model at all. That is why 5.5 can run a complete graph with no provider. Lesson 08F.10 teaches it properly; 08F.1 section 3.4 shows its API shape and the support-agent graph.
1.4 LangSmith: the platform#
LangSmith is LangChain Inc's hosted platform. It is the one part of the ecosystem that is a service, not just a package, and it is framework-agnostic: the docs say plainly that you can use it to trace, debug and evaluate agents built with any framework, not only LangChain. Its main capabilities:
- Observability: tracing of every model call, tool call and graph step, dashboards, rules and automations, and feedback collection.
- Evaluation: datasets, experiments and evaluators (Module 10A teaches the general ideas).
- Prompts: a hub for storing and versioning prompts.
- Deployment: hosting for agents (see 1.6).
The Python SDK (langsmith) is a normal MIT-licensed package that langchain-core already depends on. The service needs an account and an API key (created at smith.langchain.com), and which features you get depends on your plan, so check the current pricing and usage pages before you rely on a specific limit. Setting it up is 5.7; the full treatment is 11A.5.
Around the core platform, LangChain Inc has launched several products in 2026. You do not need them for this module, so they get one line each in 6.3: Studio, Fleet, Engine, LLM Gateway and Sandboxes.
1.5 Deep Agents: the harness#
Deep Agents (package deepagents, import from deepagents import create_deep_agent) is the newest layer. Its overview page describes it as the agent harness for complex, multi-step work: it adds planning, a virtual filesystem for context, subagent spawning and long-term memory on top of LangChain and LangGraph. Where create_agent gives you a loop and lets you add everything else, create_deep_agent gives you the loop plus a built-in toolbox and prompts, chosen for long-running tasks such as research or coding. It is MIT-licensed, pre-1.0 (0.7.38 on 14 November 2026) and the docs say its API may change between minor versions. 6.1 is the survey.
1.6 Agent Server: the deployment runtime#
Agent Server is what you reach for when the agent has to be a service: an HTTP API with assistants (versioned configurations of a graph), threads (conversations with persisted state) and runs (one execution), plus background runs, cron jobs, streaming and a task queue, backed by Postgres and Redis. You will see it called three things:
- "LangGraph Server" (and "LangGraph Platform") in material from 2024 and 2025,
- "LangSmith Deployment" in material from late 2025 and early 2026,
- "LangSmith Agent Server" in the docs today (the deployment page says "LangSmith Deployment is now LangSmith Agent Server").
It is the same runtime under three names. The PyPI packages (langgraph-api, langgraph-cli, langgraph-sdk) and the Docker image name (langchain/langgraph-api) kept the old name. 6.2 covers hosting options and licensing at survey level; 11A.5 shows how to run it locally.
1.7 The naming map: older names and current names#
The renames are the single biggest source of confusion when you search the web, so here is the table. Use it as a decoder for blog posts and Stack Overflow answers.
| Older name you may read | Name in the docs on 14 November 2026 | Notes |
|---|---|---|
| LangGraph Platform, then LangSmith Deployment, or "LangGraph Server" | LangSmith Agent Server | Packages and CLI keep the langgraph-* names |
| LangGraph Studio | LangSmith Studio | Some template READMEs still say "LangGraph Studio" |
| Agent Builder | LangSmith Fleet (no-code agents) | The docs state the rename on the Fleet page |
| "Deep Agents" command-line tool | Deep Agents Code (dcode) |
Separate package, deepagents-code |
LangChain (everything, pre-1.0) |
langchain (small, agent-focused) plus langchain-core plus langchain-classic (legacy) |
See Part 3 |
langchain-mcp-adapters |
langchain.mcp inside langchain (beta) |
The old package still exists on PyPI; its repository is archived |
langgraph.prebuilt.create_react_agent |
langchain.agents.create_agent |
See 4.4 |
langgraph-supervisor |
The "subagents" pattern with create_agent |
Package is "no longer actively maintained" and its repository is archived |
langsmith-sdk repository |
langsmith-python and langsmith-javascript repositories |
The old repository is archived; the PyPI package is still langsmith |
1.8 Product, repository and package are three different things#
One more source of confusion: the same word can name a product, a GitHub repository and a PyPI package, and they do not always line up.
| Word | As a product | As a repository | As a PyPI package |
|---|---|---|---|
| "LangChain" | the framework and the company's umbrella brand | langchain-ai/langchain, a monorepo holding langchain-core, langchain, langchain-classic and several partner packages |
langchain is only the agent-focused package |
| "LangGraph" | the runtime | langchain-ai/langgraph, which also holds the checkpointers, the CLI and the SDKs |
langgraph is the graph library; checkpointers and the CLI are separate packages |
| "Community" | loosely, "the integrations" (sunset: see 3.7) | langchain-ai/langchain-community (its own repository, separate from the monorepo; archived) |
langchain-community (sunset, last release 0.4.2) |
Part 2: A short history, 2022 to 2026#
Deep-dive
2.1 The timeline#
The official "philosophy" page keeps a history. It is worth knowing because the API you find in a tutorial depends on when the tutorial was written.
| Date | Event | What it means for old tutorials |
|---|---|---|
| October 2022 | langchain 0.0.1: LLM abstractions and "Chains" |
The "chain" era: LLMChain and friends |
| December 2022 | First general-purpose agents (based on the ReAct paper; the model emits JSON, a parser extracts the tool call) | AgentExecutor, text-ReAct prompts |
| January 2023 | OpenAI Chat Completions API (lists of messages); LangChain JavaScript released | Chat models replace plain "LLMs" |
| February 2023 | LangChain Inc. formed | |
| March 2023 | OpenAI function calling; LangChain makes native tool calling the preferred method | Tool-calling agents replace parsing text |
| June 2023 | LangSmith released (closed source) | Tracing arrives |
| January 2024 | langchain 0.1.0, the first release that is not 0.0.x |
|
| February 2024 | LangGraph released (open source) | Graph-based agents begin |
| June 2024 | 700+ integrations; integrations split into partner packages or langchain-community |
Imports change from langchain.chat_models.ChatOpenAI to langchain_openai.ChatOpenAI |
| October 2024 | LangGraph becomes the recommended way to build anything beyond a single call; most chains and agents are deprecated with migration guides; create_react_agent is created in LangGraph |
Tutorials mix AgentExecutor and langgraph.prebuilt.create_react_agent |
| April 2025 | Multimodal message format added to langchain-core |
|
| October 2025 | 1.0 of langchain, langchain-core and langgraph. All chains and agents are replaced by one agent abstraction (create_agent) built on LangGraph; standard message content format; old code stays available through langchain-classic |
Anything before this uses the old structure |
| 2025 to 2026 | Deep Agents (first PyPI release July 2025; the docs' history page dates its open-source launch to March 2026, v0.5.3), Agent Server renames, langchain.mcp, Python 3.11 floor (see 2.3); langchain-community and langchain-experimental sunset in May 2026 (see 3.7) |
Imports from the two sunset packages are now a migration task |
A note on dates: the docs give 20 October 2025 for the 1.0 announcement, while the PyPI upload date for langchain 1.0.0 (and for langchain-core and langgraph 1.0.0) is 17 October 2025. "October 2025" is the safe statement.
2.2 Why the API kept changing#
Four forces, all visible in the timeline, explain the churn. Knowing them helps you predict what will change next and avoid building on the parts that move.
- Models changed under the library. Text completion became chat, then native tool calling, then structured output, then reasoning and multimodal content. Each shift made some abstraction redundant (Module 03 covers the provider side).
- Agents moved from prompt tricks to loops with state. A fixed
Chaincould not express "call tools until done, but pause for approval". Graphs could, so the agent loop moved into LangGraph. - The integration count exploded. Hundreds of providers in one repository became unmaintainable, so integrations were split into partner packages with their own release cycles.
- A rapid-release culture. Minor releases ship often and patches several times a week. That is good for getting provider features early and tiring if you do not pin and test.
2.3 The release timeline since 1.0#
From PyPI upload dates and the official changelog. Read the headline column as "what a 1.x user gained", not as a complete list.
| Package | Version | Date | Headline |
|---|---|---|---|
langchain |
1.0.0 | 17 Oct 2025 | create_agent, middleware, standard content blocks, namespace reduction |
langchain |
1.1.0 | 24 Nov 2025 | Model profiles (a .profile attribute on chat models, derived from models.dev), ModelRetryMiddleware, SystemMessage accepted as system_prompt, flexible SummarizationMiddleware triggers |
langchain |
1.2.0 | 15 Dec 2025 | Tool extras attribute for provider-specific tool parameters; strict schema in ProviderStrategy |
langchain |
1.3.0 | 12 May 2026 | version="v3" event streaming for agents |
langchain |
1.4.0 | 1 Sep 2026 (changelog) | Built-in langchain.mcp (beta), replacing langchain-mcp-adapters |
langchain |
1.4.6 | 14 Oct 2026 | HumanInTheLoopMiddleware(interrupt_mode="per_call") |
langchain |
1.5.0 | 11 Nov 2026 | Decisions API, ModelRouterMiddleware, AutoModeMiddleware (beta), refusal content blocks, summarizer option on SummarizationMiddleware, Python 3.10 dropped |
langchain-core |
1.7.0 | 22 Oct 2026 | Event streaming of tool-call arguments as tool-call-delta events (a breaking change to iterating message.tool_calls chunks from 1.6.13) |
langgraph |
1.1.0 | 10 Mar 2026 | version="v2" stream and invoke output types |
langgraph |
1.2.0 | 12 May 2026 | DeltaChannel (beta), per-node timeouts, node error handlers, graceful shutdown, event streaming |
deepagents |
0.7.0 | 24 Jul 2026 (changelog) | Lean prompts; planning todos made opt-in |
Two things stand out. First, the pace: langchain shipped 1.4.10 on 10 November and 1.5.0 on 11 November 2026, and langchain-core shipped 1.7.5, 1.7.6, 1.7.7 and 1.8.0 in the week before. Second, a minor release can raise the Python floor (1.5.0 did) and a minor release of langchain-core can change a streaming shape (1.7.0 did). Both are allowed under the project's policy, which is why the next section matters.
2.4 What "stable" means now: the version policy#
The versioning and release-policy pages state the rules. They are the main reason 1.x is a safe place to build, so learn them.
- Semantic versioning. Breaking changes only in major versions; minor versions add features and stay backward compatible; patches fix bugs.
- Stability labels. Stable APIs carry no prefix. Beta means "feature-complete but may undergo minor changes". Alpha is experimental. Deprecated APIs say so in their docs and emit a warning. A leading underscore means internal. (
langchain.mcpandAutoModeMiddlewareare beta today;deepagentsas a whole is pre-1.0.) - Long-term support. LangChain 1.0 and LangGraph 1.0 are LTS: active until 2.0 is released, after which 1.0 enters maintenance for at least a year. LangChain 0.3 and LangGraph 0.4 are in maintenance until December 2026, which is next month: if you maintain a 0.3 project, plan the migration now.
- Deprecations last the whole major. Deprecated features keep working throughout the 1.x series; removal happens in 2.0. (The
LangGraphDeprecatedSinceV10warning you will meet in 4.4 says exactly that: "to be removed in V2.0".) - Cadence.
langchainandlangchain-coreminors "may be released frequently" and patches up to a few times a week. LangGraph majors are at least 6 to 12 months apart, minors every one to two months, patches often weekly. - Partner packages. Those maintained by LangChain (
langchain-openai,langchain-anthropic) follow semver; others may not.
What this means for you: the promise is "your 1.0 code keeps working through 1.x", not "nothing ever changes". Beta features, provider packages and the Python floor are the places where surprises still happen. Commit your lockfile, upgrade deliberately and read the changelog (see 5.10).
Part 3: The package map#
LangChain is a family of PyPI packages that you install separately. Knowing which package owns which import is what lets you fix an ImportError in one minute instead of one hour. The hyphen in a PyPI name becomes an underscore in the import name (langchain-core is imported as langchain_core).
3.1 The whole family at a glance#
Versions are from PyPI on 14 November 2026.
| PyPI name | Import name | Latest | Python | What it is |
|---|---|---|---|---|
langchain-core |
langchain_core |
1.8.0 | >=3.11 | The base abstractions: Runnables and LCEL, messages, prompts, output parsers, tools, the chat-model base classes, embeddings, vector-store and retriever interfaces, callbacks |
langchain |
langchain |
1.5.0 | >=3.11 | create_agent, middleware, init_chat_model, init_embeddings, message and tool re-exports, rate limiters, langchain.mcp (beta) |
langchain-classic |
langchain_classic |
1.0.8 | >=3.10 | The legacy code: old chains, AgentExecutor, memory classes, old retrievers, the indexing API, the hub, community re-exports |
langchain-text-splitters |
langchain_text_splitters |
1.1.3 | >=3.10 | Text splitters (chunking) |
langchain-community |
langchain_community |
0.4.2 | >=3.10 | Community-contributed integrations (the long tail). Sunset and archived (3.7) |
langchain-experimental |
langchain_experimental |
0.4.2 | >=3.10 | Experimental code, for example Python-REPL tools. Sunset and archived (3.7) |
langsmith |
langsmith |
0.14.17 | >=3.10 | The LangSmith SDK: @traceable, datasets, evaluators |
langchain-protocol |
langchain_protocol |
0.0.21 | >=3.10 | Python bindings for the agent streaming protocol (alpha); a dependency of langchain-core 1.8 |
langchain-tests |
langchain_tests |
1.1.9 | >=3.10 | Standard tests for people who write integrations |
langgraph |
langgraph |
1.2.22 | >=3.10 | StateGraph and the runtime |
deepagents |
deepagents |
0.7.38 | >=3.11 | The Deep Agents harness (pre-1.0) |
The provider packages (langchain-openai and friends) are listed in 3.5 and the LangGraph satellites in 3.9.
3.2 What uv add langchain installs#
langchain 1.5.0 declares three direct requirements: langchain-core>=1.8.0,<2, langgraph>=1.2.12,<1.3.0 and pydantic>=2.7.4. So installing langchain also installs LangGraph (and, through it, the checkpoint, prebuilt and SDK packages) and langchain-core (and, through it, langsmith, langchain-protocol, tenacity, jsonpatch and others). It does not install any provider package, the text splitters, langchain-community or langchain-classic.
flowchart LR
subgraph you ["What you add"]
lcpkg["langchain"]
prov["langchain-openai /<br/>langchain-anthropic /<br/>langchain-google-genai"]
end
subgraph pulled ["Pulled in automatically"]
core["langchain-core"]
lg["langgraph"]
pyd["pydantic"]
ls["langsmith"]
proto["langchain-protocol"]
lgpre["langgraph-prebuilt"]
lgck["langgraph-checkpoint"]
lgsdk["langgraph-sdk"]
end
lcpkg --> core
lcpkg --> lg
lcpkg --> pyd
prov --> core
prov --> sdk["provider SDK<br/>(openai, anthropic, google-genai)"]
core --> ls
core --> proto
lg --> lgpre
lg --> lgck
lg --> lgsdk
lg --> coreHere is the real tree for a project that added the packages from the Setup section, with pytest as a development dependency (uv tree --depth 1, run on 14 November 2026):
langchain-lab v0.1.0
├── langchain v1.5.0
├── langchain-anthropic v1.7.10
├── langchain-google-genai v4.5.0
├── langchain-openai v1.8.0
├── langgraph v1.2.22
├── python-dotenv v1.2.4
└── pytest v9.2.0 (group: dev)And the weight, measured on 15 November 2026 in three throwaway projects on macOS with Python 3.13 (uv pip list --format freeze | wc -l, which counts every installed package including transitive ones, and none of the header lines):
| Project | Installed packages |
|---|---|
uv add openai anthropic python-dotenv (two provider SDKs, no framework) |
18 |
uv add langchain alone |
39 |
uv add langchain langgraph langchain-openai langchain-anthropic langchain-google-genai python-dotenv plus pytest |
62 |
Other platforms differ by a few packages (Windows adds a terminal-colour helper package, for example), and the numbers drift upwards as releases add dependencies. (uv.lock counts differently: it has one entry per package it resolved, including your own project and platform-specific packages that your machine does not install, so its entries are two to three higher: 20, 41 and 65 here. Compare like with like.) The framework roughly doubles the dependency count compared with raw SDKs. That is not a verdict (the extra packages buy you the graph runtime, tracing and the message model), but it is a number to know when you apply the dependency-hygiene advice of 03.11, section 13.9 and 08F.1, Part 5.
3.3 Inside langchain 1.x#
langchain/__init__.py contains only __version__. The package is a handful of modules, each importable by name (the table in 1.2 lists them with the lessons that teach them). The one that grows fastest is langchain.agents.middleware. In 1.5.0 it exports these middleware classes (read from the installed package's __all__):
AgentMiddleware (the base class for writing your own), SummarizationMiddleware, ContextEditingMiddleware, HumanInTheLoopMiddleware, ModelFallbackMiddleware, ModelRetryMiddleware, ModelCallLimitMiddleware, ModelRefusalMiddleware, ModelRouterMiddleware, AutoModeMiddleware (beta), ToolCallLimitMiddleware, ToolRetryMiddleware, ToolErrorMiddleware, LLMToolSelectorMiddleware, ProviderToolSearchMiddleware, PIIMiddleware, TodoListMiddleware, FilesystemFileSearchMiddleware, ShellToolMiddleware and LLMToolEmulator. The same module also exports decorator forms for writing a hook of your own as a plain function (before_agent, before_model, after_model, after_agent, wrap_model_call, wrap_tool_call, dynamic_prompt and hook_config), plus the request, response and configuration types they use. The decorators are the quickest way to write a custom hook, and 08F.8 teaches them.
You do not need to learn these now. The point is the shape: the behaviours that 08F.1 and 08A.14 taught you to bolt around an agent loop (budgets, retries, approvals, PII handling, summarization, fallbacks) are exported ready-made, and 08F.8 teaches how to compose them.
3.4 langchain-core: the shared vocabulary#
langchain-core is the package that every other package depends on, and the one least likely to change shape. It holds the interfaces (what a chat model, an embedding model, a vector store, a retriever, a tool and a message look like) and the Runnable protocol that lets you compose them with | (08F.7). Prompts and output parsers (08F.6) and the in-memory vector store used in 08F.9 also live here. It contains no provider code.
That split is the design idea behind the whole ecosystem: provider packages implement langchain-core's interfaces, and your application code talks to the interfaces. It is the same principle as the provider-agnostic client you built in 03.11, published as a library.
3.5 Provider packages: langchain-openai, langchain-anthropic and the rest#
A provider package (also called a partner package) contains the chat-model, embedding and sometimes tool classes for one vendor. pip install langchain does not install any of them, so a model string such as "openai:gpt-6-luna" fails until langchain-openai is installed. (init_chat_model raises an ImportError naming the package to install.)
In the order this course always uses:
| Provider | PyPI package | Latest (14 Nov 2026) | Main class | init_chat_model prefix |
Key environment variable |
|---|---|---|---|---|---|
| OpenAI | langchain-openai |
1.8.0 | ChatOpenAI |
openai: |
OPENAI_API_KEY |
| Anthropic | langchain-anthropic |
1.7.10 | ChatAnthropic |
anthropic: |
ANTHROPIC_API_KEY |
| Gemini (Developer API) | langchain-google-genai |
4.5.0 | ChatGoogleGenerativeAI |
google_genai: |
GOOGLE_API_KEY or GEMINI_API_KEY |
| OpenRouter | langchain-openrouter |
0.2.9 | ChatOpenRouter |
openrouter: |
OPENROUTER_API_KEY |
Other packages you will meet: langchain-google-vertexai 3.3.0 (Gemini through Vertex AI; some parts are deprecated in favour of langchain-google-genai), langchain-aws 1.9.3 (Bedrock), langchain-azure-ai 1.3.1, langchain-ollama 1.1.0, langchain-huggingface 1.2.3, langchain-mistralai 1.1.6, langchain-groq 1.1.3, langchain-fireworks 1.7.3, langchain-xai 1.3.0, langchain-cohere 0.6.0 and langchain-litellm 0.11.2 (a wrapper over the LiteLLM router, labelled Beta on PyPI). Vector stores and embeddings have the same pattern: langchain-chroma, langchain-qdrant, langchain-pinecone, langchain-postgres (pgvector and others), langchain-voyageai, langchain-nomic (08F.9 uses them).
Three practical rules:
- Install by extra or by name. Both
uv add langchain-openaianduv add "langchain[openai]"work. The extras onlangchainareanthropic,aws,azure-ai,baseten,community,deepseek,fireworks,google-genai,google-vertexai,groq,huggingface,mcp,meta,mistralai,ollama,openai,perplexity,togetherandxai; each pulls the matchinglangchain-<provider>package. Installing the package by name makespyproject.tomlmore explicit, which most teams prefer. - The Gemini variable (optional provider). The Module 03 convention is
GEMINI_API_KEY.langchain-google-genaireads bothGOOGLE_API_KEY(checked first) andGEMINI_API_KEY(verified in the installed 4.5.0 source), so the course's.envworks unchanged. If both are set,GOOGLE_API_KEYwins. - Prefix spelling is exact. The Gemini prefix is
google_genaiwith an underscore. A prefix with a hyphen (google-genai:) appears in one docs example but is not recognized by the registry in the version checked; use the underscore. A bare name starting withgeminiis inferred as Vertex AI today and emits a deprecation warning, so always give the prefix. 08F.5 teachesinit_chat_modelfully.
OpenRouter deserves a note because Module 03 reaches it through the openai SDK with a base_url. LangChain now has a dedicated langchain-openrouter package and the openrouter: prefix; the model documentation recommends the dedicated class over pointing ChatOpenAI at a router, because ChatOpenAI targets the official OpenAI specification and does not extract non-standard fields that third-party endpoints return. OpenRouter is an optional gateway in this course.
Where the code lives. The langchain-ai/langchain monorepo (default branch master, MIT) holds libs/core (langchain-core), libs/langchain_v1 (langchain), libs/langchain (langchain-classic, a naming trap), libs/text-splitters, libs/standard-tests and libs/partners/ with anthropic, chroma, deepseek, exa, fireworks, groq, huggingface, mistralai, nomic, ollama, openai, openrouter, perplexity, qdrant and xai. Google, AWS, Azure, Pinecone and Postgres integrations live in their own repositories, which matters when you file an issue or look for a changelog.
3.6 The smaller packages#
langchain-text-splittersholdsRecursiveCharacterTextSplitterand friends (importlangchain_text_splitters). It is not installed bylangchain:uv add langchain-text-splitterswhen you need it (verified: a project with onlylangchaininstalled raisesModuleNotFoundError: No module named 'langchain_text_splitters'). Module 05 owns chunking strategy; 08F.9 shows the LangChain wrappers.langsmithis installed automatically bylangchain-core. Importing it does nothing until you turn tracing on.langchain-protocolis a new alpha package for the agent streaming protocol; you will see it inuv treeand can ignore it.langchain-testsis for authors of integrations.langchain-cli(0.0.37, last released August 2025) is a template tool you do not need.
3.7 langchain-community and langchain-experimental#
Both packages are sunset and their repositories are archived. This is the single most important fact on this page for anyone reading older tutorials, because most of them import from these packages.
langchain-communitywas the catalogue of integrations that were not worth their own package: community-contributed loaders, tools, vector stores and models (its PyPI summary is "Community contributed LangChain integrations"). LangChain Inc announced its sunset on 22 May 2026 in a GitHub issue (langchain-community #674), which says the sunset "will take effect immediately" and that the package "has already been effectively deprecated for more than a year". The repository was archived on 19 June 2026 ("No longer maintained, see linked issue"). 0.4.2, released on 22 May 2026, is the last release.langchain-experimental(the home of experimental code such asPythonREPL) is archived too (langchain-experimental #87, opened the same day). Its 0.4.2, also 22 May 2026, is the last release on PyPI.
Both packages still install, and old imports keep working, but nothing is fixed or updated any more: no new provider API, no security patch. The maintainers' own reasons are worth reading, because they apply to every dependency you choose: the packages had grown into a very large number of integrations of widely varying maturity on one shared release cycle, the important integrations had already moved into dedicated packages, and, in their words, it is often simpler to implement tools directly in application code (or to consume them over MCP).
Treat any import from either package as a migration task, not a dependency to add. Rules of thumb:
- Look for a dedicated package first. The integrations catalogue lists the partner packages (
langchain-openai,langchain-chroma,langchain-ollamaand many more).langchain_openai.ChatOpenAIis maintained alongside the provider's SDK;langchain_community.chat_models.ChatOpenAIis an old copy. - If no package exists, write the 10 to 30 lines yourself (a loader for an unusual file type, a thin wrapper around an HTTP API as a
@tool), or consume the capability over MCP (08E.1). The maintainers say in the sunset issue that this is often simpler. - If you must keep an old import for now, let the lockfile fix the version (
uv.lockalready records 0.4.2) and put the port in the backlog. Remember thatlangchain-communitypulls large dependency trees, so removing it also shrinks your supply chain (03.11, 13.9).
Old tutorials import from langchain_community constantly (from langchain_community.llms import ...), which is how it ends up in projects that do not need it. Replace such imports with the partner package where one exists (see the table in 4.2). If a later lesson of this module shows a langchain_community loader or retriever in a sample because the class lives nowhere else, read that sample as a migration candidate, not as a recommendation.
On langchain-experimental, keep the supply-chain framing: anything that runs model-written code (a Python REPL tool, for example) is a security decision, not a convenience. The maintainers themselves say PythonREPL "predates the safer execution environments we now recommend", which are the sandboxes and interpreters of Deep Agents. See 08A.15 and Module 12 before you run generated code anywhere.
3.8 langchain-classic: the legacy package#
langchain-classic (import langchain_classic, 1.0.8, Production/Stable on PyPI) is the home of everything that 1.0 removed from langchain: legacy chains (LLMChain, ConversationChain, RetrievalQA...), AgentExecutor and the old agent factories, the memory classes, the old retrievers module, the indexing API, the hub, CacheBackedEmbeddings and many re-exports from langchain-community. It exists so that a 0.3 codebase can start running on 1.x by changing its imports, while you migrate at your own pace. Its module tree (1.0.8) is: adapters, agents, callbacks, chains, chat_models, document_loaders, document_transformers, embeddings, evaluation, graphs, hub, indexes, llms, load, memory, output_parsers, prompts, retrievers, runnables, smith, storage, tools, utilities, vectorstores and text_splitter.
Treat it as a bridge, not a destination. Its deprecated classes say removal="2.0.0", and Part 4 covers when you would install it.
3.9 The LangGraph family#
langgraph is the library you import, but several satellite packages exist. Versions are from 14 November 2026.
| PyPI name | Latest | What it is | Do you install it directly? |
|---|---|---|---|
langgraph |
1.2.22 | StateGraph, the Functional API and the runtime |
Yes (or via langchain) |
langgraph-prebuilt |
1.1.2 | ToolNode, tools_condition, ToolRuntime, the deprecated create_react_agent |
No, arrives with langgraph |
langgraph-checkpoint |
4.3.2 | Checkpointer base classes and the in-memory saver | No, arrives with langgraph |
langgraph-checkpoint-sqlite |
3.1.3 | SQLite checkpointer | When you want a file-backed saver (08F.11) |
langgraph-checkpoint-postgres |
3.2.1 | Postgres checkpointer | For production persistence |
langgraph-checkpoint-redis, -aws |
0.6.0, 1.2.7 | Redis and AWS-backed checkpointers | If you use those stores |
langgraph-checkpoint-duckdb |
2.0.2 | DuckDB checkpointer | Last released January 2025: treat as stale |
langgraph-sdk |
0.4.14 | Python client for Agent Server | Arrives with langgraph; you call it when talking to a deployed server |
langgraph-cli |
0.4.43 | langgraph dev, up, build, deploy; extra [inmem] for langgraph dev (the extra applies only on Python 3.11 or newer) |
For local server work (11A.5) |
langgraph-api, langgraph-runtime-inmem |
0.18.0, 0.38.0 | The server implementation (both require Python 3.11 or newer, unlike langgraph itself) |
Pulled in by the CLI or by the server image |
langgraph-supervisor |
0.0.31 | Supervisor-pattern helper | No. Not actively maintained; repository archived (see 4.7) |
langgraph-swarm |
0.1.0 | Swarm-pattern helper | Covered in 08F.13. Its repository is not archived (commits to October 2026), but the last release is from December 2025: read 08F.13 before depending on it |
3.10 What do I install for...?#
| I want to... | Install |
|---|---|
| Try the keyless samples in this lesson | langchain (which brings langgraph) |
| Build a tool-using agent on one provider | langchain plus that provider's package, for example langchain-openai |
| Build a graph with plain-Python nodes | langgraph |
| Remember conversations across runs in a file | add langgraph-checkpoint-sqlite |
| Split documents for retrieval | add langchain-text-splitters |
| Use an MCP server's tools | "langchain[mcp]" |
| Load a rare file type | A dedicated package from the integrations catalogue, or your own loader; not langchain-community (sunset, 3.7) |
| Run an old 0.3 tutorial unchanged | langchain-classic (see Part 4) |
| Try a long-running research agent | deepagents |
| Trace runs | nothing extra: langsmith is already installed; set environment variables |
| Run an agent server locally | "langgraph-cli[inmem]" (Python 3.11 or newer) |
3.11 The import cheat sheet#
Every import below was executed against the packages in the Setup section on 14 November 2026 (see 5.5 for the method). Keep this table next to you while reading old code.
| You want | Current import |
|---|---|
| Build an agent | from langchain.agents import create_agent |
| Agent middleware | from langchain.agents.middleware import SummarizationMiddleware, HumanInTheLoopMiddleware, ModelFallbackMiddleware, PIIMiddleware, ModelCallLimitMiddleware |
| A chat model from any provider | from langchain.chat_models import init_chat_model |
| An embedding model from any provider | from langchain.embeddings import init_embeddings |
| Messages | from langchain.messages import HumanMessage, AIMessage, SystemMessage, ToolMessage |
| A tool | from langchain.tools import tool |
| A rate limiter | from langchain.rate_limiters import InMemoryRateLimiter |
| Prompt templates | from langchain_core.prompts import ChatPromptTemplate, MessagesPlaceholder |
| Output parsers | from langchain_core.output_parsers import StrOutputParser |
| Runnables (LCEL) | from langchain_core.runnables import RunnableLambda, RunnableParallel, RunnablePassthrough |
| Documents and an in-memory vector store | from langchain_core.documents import Document, from langchain_core.vectorstores import InMemoryVectorStore |
| A fake chat model for tests | from langchain_core.language_models.fake_chat_models import GenericFakeChatModel |
| Text splitters | from langchain_text_splitters import RecursiveCharacterTextSplitter (needs langchain-text-splitters) |
| Build a graph | from langgraph.graph import StateGraph, MessagesState, START, END |
| Pause and resume | from langgraph.types import interrupt, Command |
| In-memory checkpointer | from langgraph.checkpoint.memory import InMemorySaver (MemorySaver is also accepted) |
| In-memory long-term store | from langgraph.store.memory import InMemoryStore |
| Prebuilt tool node and router | from langgraph.prebuilt import ToolNode, tools_condition |
| Tracing decorator | from langsmith import traceable |
| Deep Agents | from deepagents import create_deep_agent |
Part 4: Legacy code and migration (how to read old tutorials)#
Reference
Why spend a whole part on code you should not write? Because most of the LangChain material on the internet (blog posts, Stack Overflow answers, YouTube courses, and the training data of the model that is helping you code) was written before October 2025. You will meet it. The skill is to date it in ten seconds and translate it. Coding assistants trained before October 2025 will suggest the old imports; the LangChain docs publish MCP servers for current answers (08F.17 says how to connect them).
4.1 What version 1 changed#
The v1 release notes and migration guide list five structural changes:
- Namespace reduction.
langchain1.x keeps only the agent-focused modules:langchain.agents,langchain.messages,langchain.tools,langchain.chat_modelsandlangchain.embeddings(see the table in 1.2). Everything else moved. - Legacy code moved to
langchain-classic: the old chains (LLMChain,ConversationChain...), retrievers such asMultiQueryRetrieverand the oldlangchain.retrieversmodule, the indexing API, thehubmodule, helpers such asCacheBackedEmbeddings, thelangchain-communityre-exports and other deprecated functionality. - One agent abstraction.
create_agentreplacesAgentExecutorand thelanggraph.prebuilt.create_react_agenthelper. Hooks (pre_model_hook,post_model_hook,state_modifier) became middleware. - Standard content blocks. A message exposes
message.content_blocks, a provider-independent view of text, reasoning, tool calls and media (08F.5). Serializing the standard blocks intocontentis opt-in withLC_OUTPUT_VERSION=v1oroutput_version="v1". - A list of breaking changes, covered in 4.6.
4.2 Old imports and where they went#
Here is what actually happens when you paste an old import into a project with langchain 1.5.0 installed. The error lines are real (run on 14 November 2026; file paths trimmed).
| Old import (pre-1.0) | What 1.x does | Current replacement |
|---|---|---|
from langchain.chains import LLMChain |
ModuleNotFoundError: No module named 'langchain.chains' |
prompt | model (08F.7); bridge: langchain_classic.chains |
from langchain.agents import AgentExecutor |
ImportError: cannot import name 'AgentExecutor' from 'langchain.agents' |
create_agent; bridge: langchain_classic.agents |
from langchain.memory import ConversationBufferMemory |
ModuleNotFoundError: No module named 'langchain.memory' |
A checkpointer for short-term memory, the Store for long-term (08F.11); bridge: langchain_classic.memory |
from langchain import hub |
ImportError: cannot import name 'hub' from 'langchain' |
Prompt versioning through LangSmith (08F.6); bridge: from langchain_classic import hub |
from langchain.llms import OpenAI |
ModuleNotFoundError: No module named 'langchain.llms' |
langchain_openai.ChatOpenAI or init_chat_model (08F.5) |
from langchain.chat_models import ChatOpenAI |
ImportError: cannot import name 'ChatOpenAI' from 'langchain.chat_models' |
from langchain_openai import ChatOpenAI, or init_chat_model("openai:...") |
from langchain.embeddings import OpenAIEmbeddings |
ImportError: cannot import name 'OpenAIEmbeddings' from 'langchain.embeddings' |
The langchain-openai embeddings class, or init_embeddings (08F.9) |
from langchain.vectorstores import Chroma |
ModuleNotFoundError: No module named 'langchain.vectorstores' |
A dedicated package such as langchain-chroma (08F.9) |
from langchain.text_splitter import RecursiveCharacterTextSplitter |
ModuleNotFoundError: No module named 'langchain.text_splitter' |
from langchain_text_splitters import RecursiveCharacterTextSplitter |
from langchain.prompts import ChatPromptTemplate |
ModuleNotFoundError: No module named 'langchain.prompts' |
from langchain_core.prompts import ChatPromptTemplate (08F.6) |
from langchain.schema import HumanMessage |
ModuleNotFoundError: No module named 'langchain.schema' |
from langchain.messages import HumanMessage |
The bridge column was verified too: with langchain-classic installed, from langchain_classic.chains import LLMChain, from langchain_classic.agents import AgentExecutor, from langchain_classic.memory import ConversationBufferMemory and from langchain_classic import hub all import.
4.3 The legacy-to-current table#
This table was checked against the langchain-classic 1.0.8 source. The "status" column says what the code itself declares, which is not always what the docs say.
| Legacy | Where it lives now | Status in the source | Current replacement |
|---|---|---|---|
LLMChain |
langchain_classic.chains |
@deprecated, "since 0.1.17", alternative "RunnableSequence, e.g., prompt | llm", removal 2.0.0 |
prompt | model (08F.7) |
ConversationChain |
langchain_classic.chains |
@deprecated since 0.2.7, alternative langchain.agents.create_agent, removal 2.0.0 |
create_agent with a checkpointer |
ConversationBufferMemory and the other memory classes |
langchain_classic.memory |
@deprecated since 0.3.1, alternative create_agent; the notice points to the short-term and long-term memory pages |
create_agent plus a checkpointer (short-term), the Store (long-term) |
RetrievalQA, ConversationalRetrievalChain |
langchain_classic.chains |
@deprecated since 0.1.17, removal 2.0.0 |
A RAG agent or a two-step chain (08F.9) |
initialize_agent |
langchain_classic.agents |
@deprecated since 0.1.0 with the agent deprecation message, removal 2.0.0 |
create_agent |
AgentExecutor |
langchain_classic.agents |
No @deprecated decorator on the class in 1.0.8 (the deprecation is carried by initialize_agent and the docs) |
create_agent |
The text-ReAct create_react_agent (used with AgentExecutor) |
langchain_classic.agents |
No decorator seen | create_agent |
langgraph.prebuilt.create_react_agent |
langgraph.prebuilt |
Deprecated: raises LangGraphDeprecatedSinceV10 when called |
langchain.agents.create_agent |
The deprecation message that initialize_agent carries is a good summary of the project's own view: "Use langchain.agents.create_agent for new applications. It provides a more flexible agent factory with middleware support, structured output, and integration with LangGraph for persistence, streaming, and human-in-the-loop workflows."
4.4 Two different functions, both called create_react_agent#
You can see the second one's deprecation yourself. Calling it with a fake model (no key needed) prints this warning (real output):
LangGraphDeprecatedSinceV10: create_react_agent has been moved to `langchain.agents`. Please update your import to `from langchain.agents import create_agent`. Deprecated in LangGraph V1.0 to be removed in V2.0.Python hides a DeprecationWarning that is raised from inside an imported module by default (it shows it for code in __main__ and under pytest), so a service or a library that calls the old function may show you nothing. Run with python -W error::DeprecationWarning or under pytest to surface every use. It still works and returns a graph, which is why old code keeps running. The deprecation policy of 2.4 means it will keep working through 1.x, and "works for now" is a reason to schedule a migration, not to skip one.
4.5 Reading an old tutorial: date it, then translate it#
Step 1: date it by its vocabulary.
| What you see in the code | The tutorial is probably from | Era |
|---|---|---|
LLMChain, .run(...), .predict(...), initialize_agent |
2023 | Chains and text agents (0.0.x to 0.1) |
AgentExecutor with a {agent_scratchpad} placeholder, ` |
` pipes everywhere | 2024 |
from langgraph.prebuilt import create_react_agent, MessageGraph, state_modifier= |
2024 to mid 2025 | LangGraph as the agent runtime (pre-1.0) |
from langchain.agents import create_agent, system_prompt=, middleware |
after October 2025 | Current |
Step 2: translate. Here is a typical 2024 tool-calling agent. This is the legacy pattern; it is shown only to be recognized.
# LEGACY (0.2/0.3 era): shown so you can recognize it. Do not write new code like this.
# On langchain 1.x the first import fails; the bridge is `from langchain_classic.agents import ...`.
from langchain.agents import AgentExecutor, create_tool_calling_agent
from langchain.tools import tool
from langchain_core.prompts import ChatPromptTemplate
from langchain_openai import ChatOpenAI
@tool
def lookup_order(order_id: str) -> str:
"""Look up an order by its ID."""
return f"Order {order_id}: shipped"
llm = ChatOpenAI(model="gpt-6-luna")
prompt = ChatPromptTemplate.from_messages(
[
("system", "You are a support agent."),
("human", "{input}"),
("placeholder", "{agent_scratchpad}"), # where the loop appended tool calls and results
]
)
agent = create_tool_calling_agent(llm, [lookup_order], prompt)
executor = AgentExecutor(agent=agent, tools=[lookup_order], verbose=True)
print(executor.invoke({"input": "Where is order A-1042?"})["output"])This sample is illustrative (it needs OPENAI_API_KEY, and its first import fails on a 1.x install without langchain-classic). The same agent today:
# current: create_agent (needs `langchain` and `langchain-openai`, and OPENAI_API_KEY)
from dotenv import load_dotenv
from langchain.agents import create_agent
from langchain.tools import tool
load_dotenv()
@tool
def lookup_order(order_id: str) -> str:
"""Look up an order by its ID."""
return f"Order {order_id}: shipped"
agent = create_agent(
model="openai:gpt-6-luna", # check the provider's model page for the current id
tools=[lookup_order],
system_prompt="You are a support agent.",
)
result = agent.invoke({"messages": [{"role": "user", "content": "Where is order A-1042?"}]})
print(result["messages"][-1].text)Order A-1042 has shipped.What changed, concept by concept:
| Legacy | Current | Why it is better |
|---|---|---|
A prompt template with an {agent_scratchpad} placeholder that you maintain |
system_prompt="..."; the loop manages the messages |
One less piece of plumbing that you could get wrong |
ChatOpenAI(...) constructed in your code |
A model string, "openai:gpt-6-luna" (or a model object if you need to configure it) |
The provider is a configuration choice (08F.5) |
executor.invoke({"input": ...})["output"] |
agent.invoke({"messages": [...]})["messages"][-1] |
The state is a message list, which is what checkpointers, streaming and middleware operate on |
verbose=True printing to the console |
Tracing (5.7) and streaming (08F.14) | Structured, inspectable, not print |
ConversationBufferMemory passed to the executor |
A checkpointer plus a thread_id in the call config (08F.11) |
Memory that survives restarts and supports time travel |
Hooks: pre_model_hook, state_modifier |
Middleware (08F.8) | A documented, composable extension point |
A second common translation, the chain: LLMChain(llm=llm, prompt=prompt).run(...) becomes prompt | model. Written out (illustrative, needs a key):
# current: a prompt piped into a model (LCEL, taught in 08F.7)
from dotenv import load_dotenv
from langchain.chat_models import init_chat_model
from langchain_core.prompts import ChatPromptTemplate
load_dotenv()
prompt = ChatPromptTemplate.from_template("Summarize this support ticket in one line: {ticket}")
chain = prompt | init_chat_model("openai:gpt-6-luna")
print(chain.invoke({"ticket": "My desk lamp arrived with a cracked base."}).text)Customer received a desk lamp with a cracked base.Step 3: check the model names and parameters. Old tutorials use retired model ids and parameters such as temperature that many current models reject or ignore (02.5, Part 6). Replace them from the provider's current model page, not from the tutorial.
Step 4: replace every langchain_community (and langchain_experimental) import. Both packages are sunset (3.7): look for a dedicated partner package, then your own code or MCP.
Step 5: ask whether the tutorial's architecture is still the one you want. A 2023 "chain of chains" for a task that is now a single structured-output call, or a hand-built ReAct loop that create_agent provides, may not need porting at all. 08F.1, Part 7 and Part 7 of this lesson help you decide.
4.6 A migration checklist for a 0.x project#
If you inherit a 0.3 application (remember that 0.3 is in maintenance only until December 2026), work through this order. Each step leaves the project in a state you can test.
- Raise Python to 3.11 or newer and lock the environment on it.
- Run your tests on the old versions and record the results, so you have a baseline. Add fake-model tests first if you have none (5.5 shows the tools).
- Upgrade the family together (
langchain,langchain-core,langgraph, and the provider packages) and installlangchain-classicas the bridge. - Fix imports using the table in 4.2. Prefer moving to partner packages and
langchain_coreoverlangchain_classicwherever the replacement is a one-line change. - Check the behaviour changes in the breaking-changes list below.
- Migrate agents from
AgentExecutororcreate_react_agenttocreate_agent, one agent at a time, comparing traces before and after. - Migrate memory from the old memory classes to a checkpointer and, where you stored facts across conversations, the
Store. - Remove
langchain-classicwhen nothing imports it (grep -r langchain_classic src/). - Commit the lockfile and add the version-pinning habits of 5.10.
The breaking changes that cause silent behaviour differences (from the migration guide):
| Change | What to do |
|---|---|
Python 3.9 dropped (and, since langchain 1.5, 3.10) |
Use 3.11 or newer |
Chat models return AIMessage, not BaseMessage |
Update type hints and isinstance checks |
langchain-openai: Responses API items are stored in message content by default |
Restore the old behaviour with output_version="v0" if you depended on it |
langchain-anthropic: the max_tokens default is now model-dependent instead of 1024 |
Set max_tokens explicitly if you relied on 1024 |
.text() method became the .text property |
Drop the parentheses; the method still works but warns and is removed in v2 |
AIMessage(example=...) removed |
Remove the argument |
create_agent: state must be a TypedDict (Pydantic and dataclass state no longer supported) |
Convert your state schema |
create_agent: pre-bound models (ChatX().bind_tools(...)) and a ToolNode in tools= are no longer accepted |
Pass the plain model and the plain tools |
| Prompted structured output removed | Use ToolStrategy or ProviderStrategy (08F.6) |
Streamed node name "agent" renamed "model" |
Update any code that filters stream events by node name |
Static run data via context= and context_schema= rather than only config["configurable"] |
See 08F.10 |
The "agent" to "model" rename is visible in the real graph of 5.5: the agent's nodes are __start__, model and __end__.
LangGraph's own migration is small: the v1 guide calls it "largely backwards compatible". Deprecated in 1.0 (still working): create_react_agent; AgentState, AgentStatePydantic and their structured-response variants in favour of langchain.agents.AgentState; HumanInterruptConfig, ActionRequest and HumanInterrupt in favour of the human-in-the-loop middleware types; ValidationNode (because create_agent validates tool input itself); and MessageGraph in favour of StateGraph with a messages key.
4.7 Moved and retired packages#
- MCP. Since
langchain1.4.0 (September 2026) the Model Context Protocol client lives insidelangchainas the betalangchain.mcpnamespace (it exposes anMCPAdapter), installed with the extra"langchain[mcp]", which pullsfastmcp. The migration page says it "replaces the standalonelangchain-mcp-adapterspackage". The old PyPI package still exists (0.3.2, August 2026) and old tutorials import from it, but its repository is archived. If you importlangchain.mcpwithout the extra, you get a real, confusing error:ModuleNotFoundError: No module named 'fastmcp'. The fix isuv add "langchain[mcp]". Importing it also emits aLangChainBetaWarning, as expected for a beta API. 08F.8 covers MCP usage and 08E.1 the protocol. langgraph-supervisoris "no longer actively maintained" per the migration page and its repository is archived (July 2026). The replacement is the subagents pattern: a supervisor built withcreate_agentwhose tools wrap worker agents (08F.13; the pattern itself is in 08D.3).langgraph-swarm(0.1.0, December 2025) is not archived (its repository had commits into October 2026), but its last release is a year old: read 08F.13 before depending on it.langchain-communityandlangchain-experimentalare sunset and archived (3.7): treat imports from them as a migration task.- JavaScript differs (see 7.7): the MCP adapter package is still current there.
4.8 Where the docs and the packages disagree#
This lesson found several disagreements while checking facts. They are exactly the kind of thing that costs an afternoon, so here they are in one place. In every case, trust the installed package over the page.
| Where | The docs say | The package says |
|---|---|---|
| Python floor | "Requires Python 3.10+" (install page, v1 migration guide) | langchain 1.5.0 and langchain-core 1.8.0 require >=3.11; langgraph 1.2.22 still allows 3.10 |
| Version attribute | The versioning page suggests langgraph.__version__ |
import langgraph; langgraph.__version__ raises AttributeError in 1.2.22. Use importlib.metadata.version("langgraph") |
AgentExecutor deprecation |
Docs treat it as legacy | The class has no @deprecated decorator in langchain-classic 1.0.8 |
| Migration guide, chains tab | The "v0 (old)" tab shows from langchain_classic.chains import LLMChain |
The real old import was from langchain.chains import LLMChain: a docs typo |
google_genai prefix |
One docs example writes google-genai: |
Only the underscore form is recognized by the registry |
| MCP | Plan and older tutorials say langchain-mcp-adapters |
langchain.mcp is current; the standalone repository is archived |
Part 5: Project setup with uv#
The goal of this part is a project that works the first time, that a teammate can recreate exactly, and that you can test without spending a cent. Everything here uses the course's standard tooling from 03.1, Part 4.
5.1 Prerequisites: Python 3.11 and uv#
- Python 3.11 or newer. 2.3 explains that the docs say 3.10 but the packages say 3.11. Python 3.13 is what this course's outputs were produced on.
uv, the package and project manager used throughout this course (03.1, 4.1 shows installation on macOS, Linux and Windows).uv initcreates a project,uv addadds a dependency and updates the lockfile,uv runruns a command inside the project's environment after checking that the lockfile is current,uv syncrebuilds the environment from the lockfile anduv removeremoves a dependency.- Optional: accounts and keys for the providers you want, and a LangSmith account for tracing. Neither is needed for 5.4 and 5.5.
5.2 Create the project#
uv init langchain-lab --bare --python 3.13 # once per project: a new folder holding only a pyproject.toml
cd langchain-lab
uv add langchain langgraph python-dotenv
uv add langchain-openai langchain-anthropic langchain-google-genai # keep only the providers you use
uv add --dev pytest(--python 3.13 matters for the reason given in 03.1: it records requires-python = ">=3.13" and makes uv pick a suitable interpreter, instead of inheriting whatever Python it finds first.)
There are no version numbers in those commands, as everywhere in this course. But uv add does write something into pyproject.toml. This is the real file after the commands above:
[project]
name = "langchain-lab"
version = "0.1.0"
requires-python = ">=3.13"
dependencies = [
"langchain>=1.5.0",
"langchain-anthropic>=1.7.10",
"langchain-google-genai>=4.5.0",
"langchain-openai>=1.8.0",
"langgraph>=1.2.22",
"python-dotenv>=1.2.4",
]
[dependency-groups]
dev = [
"pytest>=9.2.0",
]Note the >= lower bounds. uv records "at least the version I just resolved", not an exact pin. The exact versions of everything that uv resolved for this project (65 entries, which include the project itself and a few platform-specific packages that your machine may not install) are in uv.lock, a file of about 320 KB that you commit to git. That split is the reason you never need == in install commands: the pyproject.toml says what you need, the lockfile says exactly what you got, and uv sync reproduces it.
pip alternative, for readers who prefer it:
python3 -m venv .venv && source .venv/bin/activate # Windows: .venv\Scripts\activate
pip install -U langchain langgraph python-dotenv langchain-openai langchain-anthropic langchain-google-genai pytest
pip freeze > requirements.txt # your own record of exact versions5.3 What goes into the project#
Use the table in 3.10 to decide what to add. The minimal sets for this module are:
| You are doing | Install |
|---|---|
| Lessons 08F.4 to 08F.8, 08F.10 to 08F.14 without a key | langchain, langgraph |
| The same, with one real provider | add that provider's langchain-<provider> package and python-dotenv |
| Lesson 08F.9 (RAG) | add langchain-text-splitters and the vector-store or embeddings packages that lesson names |
| Lesson 08F.11 with a file-backed checkpointer | add langgraph-checkpoint-sqlite |
| Lesson 11A.5 (local server) | add "langgraph-cli[inmem]" (needs Python 3.11 or newer, which this project already requires) |
A project layout that you can grow into, using nothing but what this lesson created:
langchain-lab/
├── pyproject.toml
├── uv.lock # commit this
├── .env # secrets: never commit
├── .env.example # variable names only: commit this
├── .gitignore # contains .env and .venv/
├── src/ # your code, as the module's lessons add it
│ └── check_setup.py
└── tests/
└── test_graph.py5.4 Verify the install#
This script prints the Python version and the version of each package. It reads installed metadata only: no key, no network call. Use it whenever someone says "it works on my machine".
# check_setup.py: print what is installed, with no provider key and no network call
import sys
from importlib.metadata import PackageNotFoundError, version
PACKAGES = [
"langchain",
"langchain-core",
"langgraph",
"langgraph-prebuilt",
"langgraph-checkpoint",
"langsmith",
"langchain-openai",
"langchain-anthropic",
"langchain-google-genai",
]
print(f"Python {sys.version_info.major}.{sys.version_info.minor}.{sys.version_info.micro}")
for name in PACKAGES:
try:
print(f"{name:24} {version(name)}")
except PackageNotFoundError:
print(f"{name:24} not installed")Run it with uv run python check_setup.py. Output (real, 14 November 2026):
Python 3.13.14
langchain 1.5.0
langchain-core 1.8.0
langgraph 1.2.22
langgraph-prebuilt 1.1.2
langgraph-checkpoint 4.3.2
langsmith 0.14.17
langchain-openai 1.8.0
langchain-anthropic 1.7.10
langchain-google-genai 4.5.0importlib.metadata.version is used on purpose. langchain.__version__ and langchain_core.__version__ exist (they printed 1.5.0 and 1.8.0 when checked), but langgraph.__version__ does not: uv run python -c "import langgraph; print(langgraph.__version__)" ends with AttributeError: module 'langgraph' has no attribute '__version__', even though the versioning page suggests it.
5.5 First runs without any key#
Three short programs, all run for real on 14 November 2026 with no provider and no network access. Together they demonstrate the two claims of Part 1 that are easiest to doubt: that LangGraph needs no model, and that create_agent returns a LangGraph graph.
A graph with one plain-Python node. This is the minimal graph from the LangGraph overview. mock_llm stands in for a model; it just returns a fixed message.
# hello_graph.py: a LangGraph graph with one plain-Python node and no model
from langgraph.graph import END, START, MessagesState, StateGraph
def mock_llm(state: MessagesState) -> dict:
# A stand-in for a model call: returns a fixed assistant message
return {"messages": [{"role": "ai", "content": "hello world"}]}
builder = StateGraph(MessagesState)
builder.add_node(mock_llm)
builder.add_edge(START, "mock_llm")
builder.add_edge("mock_llm", END)
graph = builder.compile()
result = graph.invoke({"messages": [{"role": "user", "content": "hi!"}]})
for message in result["messages"]:
print(type(message).__name__, "|", message.content)HumanMessage | hi!
AIMessage | hello worldNotice that the dictionaries you passed in came back as HumanMessage and AIMessage objects. MessagesState has a reducer on its messages key that appends new messages and converts dictionaries to message objects. Lesson 08F.10 explains reducers; for now, notice that you ran a real graph with state, a node and edges in ten lines.
A fake chat model. GenericFakeChatModel replays messages you supply. It is how you test LangChain code with no key (08F.1, 5.2 and 11A.5 cover testing).
# fake_model.py: a chat model that needs no key, to prove the install works
from langchain_core.language_models.fake_chat_models import GenericFakeChatModel
from langchain_core.messages import AIMessage
model = GenericFakeChatModel(messages=iter([AIMessage(content="Pong from a fake model.")]))
reply = model.invoke("ping")
print(type(reply).__name__, "|", reply.content)AIMessage | Pong from a fake model.A real create_agent agent on the fake model. This one proves that the agent is a compiled graph, and shows the node names that the migration table of 4.6 mentioned (model, not agent). The fake model makes one reply and calls no tools, so the loop ends after a single model step.
# agent_is_a_graph.py: create_agent returns a compiled LangGraph graph (no provider is called)
from langchain.agents import create_agent
from langchain_core.language_models.fake_chat_models import GenericFakeChatModel
from langchain_core.messages import AIMessage
fake = GenericFakeChatModel(messages=iter([AIMessage(content="Hello from the agent loop.")]))
agent = create_agent(model=fake, system_prompt="You are terse.")
print(type(agent).__module__, type(agent).__name__)
print(sorted(agent.get_graph().nodes))
result = agent.invoke({"messages": [{"role": "user", "content": "hi"}]})
print([type(m).__name__ for m in result["messages"]], "|", result["messages"][-1].content)langgraph.graph.state CompiledStateGraph
['__end__', '__start__', 'model']
['HumanMessage', 'AIMessage'] | Hello from the agent loop.CompiledStateGraph from langgraph.graph.state is the same class StateGraph.compile() returned in the first program. That is the whole architecture of Part 1 demonstrated in six lines: the framework's agent is a graph of the runtime.
The cheat sheet of 3.11 was checked the same way: a script importing every name in the table ran without errors on this install (the splitters and the Deep Agents entry need their own packages, which were added for that check).
5.6 Keys and environment variables#
Provider packages read their key from environment variables when you do not pass one, so the usual flow is: put the key in .env, call load_dotenv() once at the start of your program, and construct the model. Never write a key in code (03.1, Part 3).
| Variable | Read by | Notes |
|---|---|---|
OPENAI_API_KEY |
langchain-openai |
|
ANTHROPIC_API_KEY |
langchain-anthropic |
|
GOOGLE_API_KEY or GEMINI_API_KEY |
langchain-google-genai |
GOOGLE_API_KEY is checked first; GEMINI_API_KEY is the course's name and works |
OPENROUTER_API_KEY |
langchain-openrouter |
|
LANGSMITH_TRACING, LANGSMITH_API_KEY, LANGSMITH_PROJECT, LANGSMITH_ENDPOINT, LANGSMITH_WORKSPACE_ID |
langsmith (see 5.7) |
|
LC_OUTPUT_VERSION |
langchain-core |
v1 serializes standard content blocks into message content (4.1) |
LANGCHAIN_CALLBACKS_BACKGROUND |
langchain-core |
Documented as a true or false switch for background tracing callbacks, but nothing in the Python packages reads it (measured in 11A.5, 2.9); use wait_for_all_tracers() or Client().flush() instead |
Commit a .env.example that lists the names with empty values, so a new teammate knows what to fill in:
# .env.example (commit this; the real .env is ignored by git)
OPENAI_API_KEY=
ANTHROPIC_API_KEY=
GEMINI_API_KEY= # optional
OPENROUTER_API_KEY= # optional gateway
LANGSMITH_TRACING=false
LANGSMITH_API_KEY=5.7 Switching tracing on#
Tracing needs no code change. With these variables set (in .env and loaded by load_dotenv(), or exported in the shell), every LangChain and LangGraph run is sent to LangSmith:
export LANGSMITH_TRACING=true
export LANGSMITH_API_KEY=... # created at smith.langchain.com, Settings, API Keys
export LANGSMITH_PROJECT=langchain-lab # optional: the project that groups your traces
# export LANGSMITH_ENDPOINT=https://eu.api.smith.langchain.com # only for non-US regions
# export LANGSMITH_WORKSPACE_ID=... # only if your key is linked to several workspacesOn Windows PowerShell the equivalent of each export line is $env:LANGSMITH_TRACING = "true"; or put the variables in .env and let load_dotenv() read them on every platform.
Older tutorials use LANGCHAIN_TRACING_V2=true and LANGCHAIN_API_KEY. The current tracing page documents only the LANGSMITH_ names, but in langsmith 0.14.17 the legacy names are still honoured as fallbacks (checked: with only LANGCHAIN_TRACING_V2=true set, langsmith.utils.tracing_is_enabled() returns True). So an old .env can switch tracing on without you meaning to. If both families are set, LANGCHAIN_TRACING_V2 takes precedence over LANGSMITH_TRACING, so a stale LANGCHAIN_TRACING_V2=true can keep tracing on even when you set LANGSMITH_TRACING=false. Use the LANGSMITH_ names in new work, and search old .env files and shell profiles for the legacy ones (grep -rn LANGCHAIN_ .env*). Remember the warning of 1.4: traces contain prompts and tool results. Keep tracing off (LANGSMITH_TRACING=false) for any run that touches data you must not send out. Everything beyond switching it on (the @traceable decorator, metadata and tags, datasets, experiments) is in 11A.5.
5.8 Your first real agent, on every provider#
The following program is the smallest agent that does something real: it gives the model one tool and lets create_agent run the loop that you wrote by hand in 08A.2. It uses the course's provider order and default models, chosen by an environment variable so that you can switch provider without editing code.
# hello_agent.py: one tool-using agent, any of four providers
import os
import sys
from dotenv import load_dotenv
from langchain.agents import create_agent
load_dotenv() # reads .env into the environment; the provider packages read their keys from there
# provider -> (model string for init_chat_model, environment variables that can supply the key)
# Model ids are volatile: check each provider's model page for the current names.
MODELS = {
"openai": ("openai:gpt-6-luna", ("OPENAI_API_KEY",)),
"anthropic": ("anthropic:claude-haiku-5-5", ("ANTHROPIC_API_KEY",)),
"gemini": ("google_genai:gemini-3.8-flash", ("GOOGLE_API_KEY", "GEMINI_API_KEY")),
"openrouter": ("openrouter:openai/gpt-6-luna", ("OPENROUTER_API_KEY",)),
}
ORDERS = {"A-1042": "shipped", "B-2077": "processing", "C-3390": "delivered"}
def lookup_order(order_id: str) -> str:
"""Look up an order by its ID and return its status."""
# The error text is written for the model to read, as in 08A.6
return ORDERS.get(order_id.strip().upper(), f"no order found with id {order_id!r}")
def main() -> None:
provider = os.getenv("PROVIDER", "openai")
if provider not in MODELS:
sys.exit(f"PROVIDER must be one of {', '.join(MODELS)}, got {provider!r}")
model, key_names = MODELS[provider]
if not any(os.getenv(name) for name in key_names):
sys.exit(f"Set {' or '.join(key_names)} in .env to use {provider!r}.")
agent = create_agent(
model=model,
tools=[lookup_order],
system_prompt="You are a support agent. Look up an order before answering about it.",
)
result = agent.invoke({"messages": [{"role": "user", "content": "Where is order A-1042?"}]})
for message in result["messages"]:
# .text is the text of the message; a tool-calling AIMessage has empty text
print(type(message).__name__, "|", message.text or getattr(message, "tool_calls", ""))
if __name__ == "__main__":
main()Run it with PROVIDER=anthropic uv run python hello_agent.py, for example. It needs a key and the matching provider package, so the sample is illustrative.
HumanMessage | Where is order A-1042?
AIMessage | [{'name': 'lookup_order', 'args': {'order_id': 'A-1042'}, 'id': 'call_1', 'type': 'tool_call'}]
ToolMessage | shipped
AIMessage | Order A-1042 has shipped.Read the output as the trajectory from 08A.2: the model asks for a tool (an AIMessage with tool_calls), the loop runs it and appends a ToolMessage, and the model answers. The tool call ids, the exact wording and the number of steps depend on the provider and model. The whole of 08F.8 is about tools and create_agent; here, notice only that the loop, the tool schema (generated from the type hints and docstring) and the message bookkeeping were not written by you.
5.9 Troubleshooting the first hour#
| Symptom | Cause | Fix |
|---|---|---|
ModuleNotFoundError: No module named 'langchain.chains' (or .memory, .llms, .vectorstores, .prompts, .schema, .text_splitter) |
An old tutorial's import | 4.2 |
ImportError: cannot import name 'AgentExecutor' from 'langchain.agents' |
Same | Use create_agent, or bridge through langchain_classic (4.5) |
ImportError mentioning a package when you build a model from a string |
The provider package is not installed (pip install langchain installs none) |
uv add langchain-openai (or the one named in the message) |
ModuleNotFoundError: No module named 'langchain_text_splitters' |
The splitters are a separate package | uv add langchain-text-splitters |
ModuleNotFoundError: No module named 'fastmcp' after import langchain.mcp |
The MCP extra is not installed | uv add "langchain[mcp]" (4.7) |
AttributeError: module 'langgraph' has no attribute '__version__' |
The attribute does not exist, despite the versioning page | Use importlib.metadata.version("langgraph") (5.4) |
LangGraphDeprecatedSinceV10: create_react_agent has been moved... |
You (or a tutorial) used the deprecated prebuilt | Switch to create_agent (4.4) |
| The resolver says "No solution found ... depends on Python>=3.11" | Something in the project asks for a langchain that needs 3.11 (for example uv add "langchain>=1.5.0") while requires-python still allows 3.10 |
Recreate with uv init ... --python 3.13, or set requires-python = ">=3.11" (03.1, 4.2) |
OpenAIError: Missing credentials, or a ValidationError ... API key required (Gemini) or OPENROUTER_API_KEY must be set, raised when you build the model or the agent |
The variable is not set yet: not in .env, misspelt, or load_dotenv() ran after the model was built (create_agent("openai:...") builds the model immediately) |
Call load_dotenv() first; check the variable name in 5.6 |
| An authentication error from the provider on a call | The key is set but wrong or revoked | Create a new key at the provider and replace it in .env |
| Everything works, but nothing appears in LangSmith | LANGSMITH_TRACING is not true, the key is wrong, or the region endpoint is missing |
Check 5.7; for non-US accounts set LANGSMITH_ENDPOINT |
After upgrading, uv run shows different behaviour |
A minor release changed a default | Read the changelog between the two versions (5.10) |
One surprise deserves its own note. If you create a project with --python 3.10 (or leave requires-python at >=3.10) and run uv add langchain, uv does not fail (the error in the table above appears only when something asks for the newer floor, such as uv add "langchain>=1.5.0"). It resolves for every Python in your declared range and writes the bound that all of them can satisfy; on 14 November 2026 that was langchain>=1.4.10, the newest line that still supports 3.10, even though the interpreter running the tests installed 1.5.0. In other words, a loose requires-python quietly lowers your dependency floors. Set requires-python = ">=3.11" or higher deliberately.
5.10 Upgrading safely#
The packages move fast (see 2.3), and that pace is the main operational cost of the ecosystem. A routine that works:
- Commit
uv.lock, and runuv sync(oruv sync --lockedin CI) so that every machine installs the locked set, not whatever is newest. - Upgrade on purpose, on a branch.
uv lock --upgrade-package langchainupgrades one package (and whatever it needs);uv lock --upgradeupgrades everything; thenuv syncand run your tests. - Upgrade the family together:
langchain,langchain-core,langgraphand the provider packages, because they declare minimum versions of one another (3.4). - Read the changelog entries between your version and the new one, not only the latest. Look for: Python floor changes, default changes in provider packages, renamed events or nodes, beta features that changed.
- Test with fake models first (5.5), so that a behaviour change shows up as a failing unit test and not as a surprising answer in production.
- Re-check traces: compare a LangSmith trace before and after for a few representative inputs.
- Mind the order for deployments. The
langchain-core1.7.0 changelog warns that a streaming change requires upgrading clients and server versions in order (clients first). - Treat new dependencies as a supply-chain event. Diff the lockfile (
git diff uv.lock), and apply the habits of 03.11, 13.9. A framework with this many transitive packages gives you this many places for a compromised release to enter.
5.11 What you have after Part 5#
A reproducible project, a verified install, three keyless programs that ran (a graph, a fake model and an agent that is a graph), a provider-switching agent sample for when you have a key, a tracing recipe and an upgrade routine. Keep langchain-lab and reuse it for the rest of the module: lesson 08F.5 starts from init_chat_model in exactly this project.
Part 6: Deep Agents, Agent Server and the rest of the platform (survey)#
Reference
This part is deliberately survey level, following the module's plan: what each piece is, its packages, licence and hosting, and when to use it. Neither Deep Agents nor Agent Server gets a walkthrough in this module (Agent Server's local use is touched in 11A.5). The official pages are more complete than any summary, and the links are in Further resources.
6.1 Deep Agents#
What it is. "The agent harness for complex, multi-step work": planning, a virtual filesystem used as external context, subagents with isolated context windows, context management (summarizing long threads, offloading large tool results), optional shell access in a sandbox, persistent memory, human-in-the-loop approvals (interrupt_on), skills and MCP tools. It is model-agnostic (any tool-calling model), MIT-licensed and built on LangChain and LangGraph, which means a Deep Agent is also a compiled graph.
Packages. deepagents (0.7.38 on 13 November 2026, Python 3.11 or newer, PyPI classifier "Beta"). It requires langchain>=1.5.0 and langchain-core>=1.8.0 and, notably, langchain-anthropic and langchain-google-genai as hard dependencies per its PyPI metadata, so installing it adds those too (importing create_deep_agent was checked in a scratch environment). Related packages include deepagents-code (the dcode command-line agent, which declares Python 3.14 only on PyPI), deepagents-acp (Agent Client Protocol) and sandbox integrations. The dcode installer in the docs is a pipe-to-shell script (curl ... | bash); read a script before you pipe it to a shell (03.11, 13.9).
Entry point (from the docs' shape; illustrative, needs a key):
# deep_agent_sketch.py: the shape of a Deep Agents program (needs `deepagents` and a provider key)
from dotenv import load_dotenv
from deepagents import create_deep_agent
load_dotenv()
def search_notes(topic: str) -> str:
"""Search the team's research notes for a topic and return matching excerpts."""
notes = {"churn": "Q3 churn rose after the March pricing change.", "nps": "NPS held steady at 41."}
return notes.get(topic.strip().lower(), "no notes found")
agent = create_deep_agent(
model="anthropic:claude-sonnet-5-5", # check the provider's model page for current ids
tools=[search_notes],
system_prompt="You are a careful research assistant for the product team.",
)
result = agent.invoke({"messages": [{"role": "user", "content": "Draft a short brief on what the notes say about churn."}]})
print(result["messages"][-1].text)This sample is illustrative: it needs a provider key and uv add deepagents, and it was written from the official overview rather than run.
Churn rose in Q3 after the March pricing change; NPS held steady, so pricing is the likely cause.Built-in tools. The harness adds filesystem tools (ls, read_file, write_file, edit_file, delete, glob, grep), a task tool that spawns a subagent, and execute only when you configure a sandbox backend. Planning with a to-do list (write_todos) is opt-in since 0.7.0 through TodoListMiddleware, imported from langchain.agents.middleware (you can see TodoListMiddleware in the list of 3.3).
Hosting. Two official routes: Managed Deep Agents (public beta at the time of writing, runs on LangSmith Agent Server on LangSmith Cloud or in your own cloud account; the agent is a project folder with instructions, skills, tools and middleware, deployed with the mda command-line tool), or self-host the Deep Agents SDK in your own process or container, with your own backends, stores and checkpointers, optionally behind your own Agent Server.
Stability and safety. It is pre-1.0 and the release policy allows breaking changes in minor releases. Real examples: 0.7.0 made planning todos opt-in and removed backend shims; 0.6.0 made rolling back unsupported after DeltaChannel checkpoints. Two security advisories (permission and approval bypasses, October 2026) were published. The cadence is extreme (three releases, 0.7.36 to 0.7.38, in the two days of 12 and 13 November 2026). The sandbox guidance deserves repeating: never put secrets inside a sandbox, because a context-injected agent can read and exfiltrate them; keep credential-bearing tools outside the sandbox. This is 08A.15 and Module 12 territory.
When to use it (the docs' wording, condensed): long-running agents, complex multi-step tasks, and when you want predefined tools (filesystem, shell), automated context engineering and ready-made prompts and subagents. Choose create_agent when you want full control and a custom architecture, and LangGraph when you want explicit control of state and flow. The official comparison with the Claude Agent SDK is a vendor comparison, not a neutral benchmark; read it as a feature list.
6.2 Agent Server (formerly LangGraph Server and LangSmith Deployment)#
What it is. A runtime that turns your graph into a service: an HTTP API over assistants, threads, runs, cron jobs, a key-value store and streaming, with built-in persistence (Postgres for checkpoints and the store, Redis for pub/sub) and a task queue. It also serves your agents over MCP (at /mcp) and the A2A protocol (at /a2a/{assistant_id}). It is framework-agnostic: graphs from LangGraph and LangChain, and agents from other frameworks, can be wrapped and deployed.
Packages and licences (PyPI, 14 November 2026).
| Package | Version | Licence on PyPI | Role |
|---|---|---|---|
langgraph-cli |
0.4.43 | MIT | langgraph dev, up, build, deploy, dockerfile (the inmem extra needs Python 3.11 or newer) |
langgraph-sdk |
0.4.14 | MIT | Python client (and the Auth helpers) |
langgraph-api |
0.18.0 | Elastic-2.0 | The server implementation (Python 3.11 or newer) |
langgraph-runtime-inmem |
0.38.0 | Elastic-2.0 | The in-memory runtime used by langgraph dev (Python 3.11 or newer) |
The server packages need Python 3.11 or newer even though langgraph itself allows 3.10, so langgraph dev is a 3.11-and-up tool. The licence metadata comes from PyPI; whether Elastic-2.0 covers every part of the server was not confirmed, and no public source repository for it was found. Read the licence before building a business on self-hosting.
Hosting options (docs, 14 November 2026).
| Mode | Who runs the control plane | Who runs the servers and databases | Plan or licence (deployment page; Hybrid from the pricing page) |
|---|---|---|---|
| Cloud (AWS, Azure or GCP; GitHub-based deploys) | LangChain | LangChain | "Requires a Plus plan or above" |
| Hybrid | LangChain | You, in your own VPC | Enterprise |
| Self-hosted with control plane | You | You | "Requires the Enterprise plan with Agent Server hosting enabled" |
| Standalone server (Docker, Compose or Kubernetes; Helm recommended for production) | None | You: bring PostgreSQL, Redis and a LangSmith licence key | A licence key (which plan unlocks it is not stated on the pages read) |
Local langgraph dev |
n/a | Your laptop | A free LangSmith account and API key |
Pricing is metered on the pricing page and changes; this lesson quotes no prices. Check langchain.com/pricing and the usage and billing pages before you plan costs.
Local development, in two commands that 11A.5 explains:
uv add "langgraph-cli[inmem]"
langgraph dev # no Docker, hot reload, default port 2024; state kept in memory and pickled to a local folder
langgraph up # needs Docker and PostgreSQL, default port 8123: closer to productionThese are commands you would run once you have a langgraph.json and a graph; they are not run in this lesson. To call a deployed graph from your own code, RemoteGraph (documented on the "use remote graph" page) lets it behave like a local graph.
When to use it. You want durable, long-running, stateful agents behind an API: assistants and threads, background and cron runs, streaming, human-in-the-loop over HTTP, built-in authentication hooks, and MCP and A2A endpoints, without building the server, queue and persistence yourself. When not to: simple scripts; in-process use, where the LangGraph library alone gives you checkpointers and interrupts; or when you must keep your own serving stack (assistants, double-texting handling and cron are server features, not library features). Full-stack JavaScript apps can embed LangChain.js directly with no server (the deployment page lists Next.js, SvelteKit, Nuxt and Cloudflare Workers).
6.3 The rest of the LangSmith family#
One line each, so the names stop being a mystery. None of these is needed for the module.
| Product | What it is | Official page (under docs.langchain.com) |
|---|---|---|
| LangSmith Studio | A visual agent IDE for Agent Server APIs, with graph and chat modes (11A.5 shows it with a local server) | /langsmith/studio |
| LangSmith Fleet | No-code agents with templates, channels and schedules (formerly Agent Builder) | /langsmith/fleet/index |
| LangSmith Engine | Turns production traces into tracked issues, proposed fixes (it can open a pull request) and datasets | /langsmith/engine |
| LLM Gateway | One endpoint for model calls with policies, fallbacks, spend limits and traces; the self-hosted version is beta | /langsmith/llm-gateway |
| LangSmith Sandboxes | Managed code sandboxes | /langsmith/sandboxes |
| Agent Registry, Prompt Hub / Context Hub, OpenWiki | Named in the docs navigation; read their pages if you need them | the docs home |
The docs home carries a compliance statement (HIPAA, SOC 2 Type 2 and GDPR details on the vendor's Trust Center); read that page directly if compliance matters to you.
Part 7: Choosing LangChain, LangGraph, both, Deep Agents or neither#
Lesson 08F.1 already compared the field and gave a framework-neutral checklist, so this part does not redo it. It answers the narrower question this module exists for: given that you are considering the LangChain ecosystem, which piece, if any?
7.1 The decision table#
| Your situation | Start with | Why |
|---|---|---|
| One model call, or a short fixed pipeline (classify, extract, summarize) | The provider SDK from Module 03, or init_chat_model if you want provider-swapping |
No loop, no state: a framework is overhead. prompt | model (08F.7) is enough |
| A tool-using agent: the model decides, tools act, no special control flow | LangChain create_agent with middleware |
The standard loop, tool handling, structured output and extension points are built; add a checkpointer when you need threads |
| An agent that must pause for approval, resume after a crash, branch deterministically or run on a schedule | LangGraph (StateGraph or the Functional API), possibly with create_agent as one node |
Explicit state and control flow, durable execution and interrupts are the runtime's reason to exist |
| A workflow where some steps are deterministic and some are agentic | Both: a LangGraph graph whose agentic steps are create_agent agents |
Each tool for what it is best at (7.3) |
| Long multi-step work: research, document drafting, coding in a sandbox | Deep Agents (or your own create_agent with the same ingredients) |
Planning, filesystem context and subagents are built in, at the price of a pre-1.0 package |
| An HTTP API with threads, background runs, cron and streaming for your agents | Agent Server (LangSmith), or your own FastAPI service around the library | The server gives you the operational layer; the library alone does not |
| You only need to see what your agent (built on anything) is doing | LangSmith tracing alone | It is framework-agnostic: no need to adopt the rest |
| You already own a good loop (08A.2) and it works | Nothing: add tracing | A working loop beats a migration you do not need |
| You need a runtime with its own guarantees, for example Temporal-style workflows across non-agent services | Temporal or Inngest (the docs' own runtime alternatives) | LangGraph is an agent runtime, not a general workflow engine |
flowchart TD
start{"What are you building?"} -->|"one model call or a short fixed pipeline"| one["Provider SDK or init_chat_model<br/>(no agent framework)"]
start -->|"an agent that calls tools in a loop"| loop{"Do you need explicit control<br/>of state, branches, pauses or crash recovery?"}
loop -->|"no"| ca["LangChain create_agent<br/>(+ middleware, + a checkpointer if you need threads)"]
loop -->|"yes"| lgq["LangGraph StateGraph or Functional API<br/>(use create_agent as a node where it fits)"]
start -->|"long multi-step work: research, coding, files"| dq{"Do you want planning, a virtual filesystem<br/>and subagents out of the box?"}
dq -->|"yes"| dag["Deep Agents<br/>(pre-1.0: pin and read the changelog)"]
dq -->|"no"| loop
start -->|"you already own a working loop"| keep["Keep it, add tracing<br/>(08A.2, 08F.1)"]
ca --> host{"Need an HTTP API, queues, cron<br/>and hosted persistence?"}
lgq --> host
dag --> host
host -->|"yes"| srv["Agent Server (LangSmith)<br/>or your own FastAPI service"]
host -->|"no"| lib["Run in your own process"]The official overview gives the same ladder in one tip: start with Managed Deep Agents for a batteries-included harness, use LangChain (create_agent) for a highly customizable harness, use LangGraph for advanced needs combining deterministic and agentic workflows, and use LangSmith to trace, debug and evaluate agents built with any of them. Treat the order as a gradient from "more decided for you" to "more control and more code to own". 08A.9 gave the general principle: use the simplest rung that works.
7.2 What "both" means in practice#
The usual question is "LangChain or LangGraph?" and the usual answer is "both, and you do not choose", because create_agent returns a LangGraph graph. Three consequences:
- Every
create_agentagent can use LangGraph features: a checkpointer for memory and pause/resume, streaming modes, interrupts, and deployment on Agent Server. You do not "move to LangGraph" to get persistence; you pass a checkpointer. - An agent is a valid node in a bigger graph. Run this keyless program (it was run on 14 November 2026; a fake model stands in for the provider):
# both.py: a create_agent agent used as one node inside a hand-written LangGraph graph
from langchain.agents import create_agent
from langchain_core.language_models.fake_chat_models import GenericFakeChatModel
from langchain_core.messages import AIMessage
from langgraph.graph import END, START, MessagesState, StateGraph
# The "agent" half: a fake model stands in for a real provider
fake = GenericFakeChatModel(messages=iter([AIMessage(content="Your order has shipped.")]))
support_agent = create_agent(model=fake, system_prompt="You are a support agent.")
def audit(state: MessagesState) -> dict:
# The "workflow" half: a deterministic step that runs after the agent
print("audit: conversation has", len(state["messages"]), "messages")
return {}
builder = StateGraph(MessagesState)
builder.add_node("support", support_agent) # a compiled graph is a valid node
builder.add_node("audit", audit)
builder.add_edge(START, "support")
builder.add_edge("support", "audit")
builder.add_edge("audit", END)
graph = builder.compile()
result = graph.invoke({"messages": [{"role": "user", "content": "Where is A-1042?"}]})
print(result["messages"][-1].content)audit: conversation has 2 messages
Your order has shipped.This is the structure of most real systems: a deterministic skeleton (validate, route, audit, notify) with agent steps where judgement is needed. 08F.13 calls a compiled graph used as a node a subgraph and teaches how state is shared or kept private.
- The same feature exists at each layer, and the layers pair up. The official feature-comparison table maps one concept to the page in each product:
| Concept | LangGraph | LangChain | Deep Agents | Taught in |
|---|---|---|---|---|
| Human-in-the-loop | interrupt() and Command(resume=...) |
HumanInTheLoopMiddleware |
interrupt_on |
08F.8, 08F.12 |
| Subagents | Subgraphs | The "subagents" multi-agent pattern | Built-in task subagents |
08F.13 |
| Memory | Checkpointers (short-term) and the Store (long-term) |
Built on the same two | Has its own memory page; see its docs | 08F.11 |
In each row the higher-level product uses the lower-level one underneath. When something goes wrong, read down the stack: the Deep Agents behaviour you do not understand is probably a LangChain middleware, and the middleware's state is a LangGraph channel.
7.3 "Both" is the normal answer#
If you remember one sentence from this part: start with create_agent; reach for LangGraph primitives when the agent loop is not the shape of your problem; use LangGraph directly (no agent loop) when your problem is a workflow with a model in some steps. The costs of the layering are small because the layers share one state model (a list of messages plus whatever you add) and one runtime.
The tempting wrong turns, from 08A.9 and 08F.1, 7.2:
- A graph for a two-tool FAQ bot. You write nodes and edges for a loop that
create_agentalready is. create_agentfor a fixed pipeline. If the steps never vary, a workflow in plain code (or a tiny graph) is cheaper, faster and testable. A model deciding "which of my three fixed steps next" when the answer is always the same is waste.- Deep Agents for a 30-second task. Planning, filesystem and subagents are overhead for work that fits in one context window.
7.4 When "neither" is right, and what LangChain costs#
Neither the provider SDK nor your own loop is a lesser choice. Prefer them when:
- The task is one call, or a short fixed pipeline: use the provider SDK with structured output (03.4).
- You already run a good loop with its own budgets, approvals and tracing (08A.2, 08A.14), and the framework would replace code that works.
- You need one provider's newest feature immediately. A provider package lags the native SDK by days, sometimes longer; the escape hatches (provider-specific parameters and the
extrasattribute on tools added inlangchain1.2.0) narrow the gap but do not remove it. - You want the smallest dependency tree: 18 packages for two SDKs against 39 for
langchainalone, measured in 3.2.
What the ecosystem has cost its users, so that you can weigh it honestly (these are facts from this lesson, not opinions):
| Cost | Evidence in this lesson |
|---|---|
| Churn | The 0.x to 1.0 migration (Part 4); a Python floor raised in a minor release (2.3); a streaming shape changed in a langchain-core minor |
| Docs that lag the code | Six disagreements found in one lesson (4.8) |
| Dependency weight | 39 packages for langchain alone; 62 for the lab project (3.2) |
| Packages retired under you | langchain-community and langchain-experimental sunset in May 2026 (3.7); langgraph-supervisor and langchain-mcp-adapters archived (4.7) |
| Naming confusion | Three names for one server, two functions called create_react_agent, langchain versus langchain-classic versus libs/langchain in the repository (1.7, 4.4, 3.5) |
| Beta and pre-1.0 surface | langchain.mcp, AutoModeMiddleware and the whole of deepagents |
And what it has bought them: a standard message and tool model across providers; a documented agent loop with extension points; a runtime with persistence, interrupts and streaming that most teams would not build; and observability that works across frameworks. Module 08F.15 returns to patterns and anti-patterns once you have used all of it.
7.5 The framework-neutral checklist, applied to LangChain#
08F.1, section 1.3 gave ten questions for any framework. Here are the LangChain-ecosystem answers, so that you can compare them with your own project. (Answers refer to langchain 1.5 and langgraph 1.2.)
| # | Question | Answer for LangChain plus LangGraph |
|---|---|---|
| 1 | What does it own? | The model and message interface, the agent loop and middleware (LangChain); state, persistence, interrupts and streaming (LangGraph). You own tool logic, prompts, evals and data |
| 2 | What does it hide? | Provider message conversion, structured-output strategy selection, default retries in the provider packages. Tracing shows what was sent; check each provider package's defaults (max_retries, timeout) |
| 3 | How do you test it? | GenericFakeChatModel (used in 5.5) and in-memory checkpointers: unit tests need no key |
| 4 | What happens on failure? | Tool errors and retries are middleware (ToolRetryMiddleware, ToolErrorMiddleware, ModelRetryMiddleware); bound the loop with ModelCallLimitMiddleware and ToolCallLimitMiddleware (08F.8). Double retries are possible: one layer should own retries |
| 5 | What is the escape hatch? | Provider classes accept provider-specific parameters, tools can carry provider-specific extras, and the native SDK stays installed |
| 6 | What is the state model? | A message list plus your schema, in graph state; durable when you add a checkpointer such as Postgres; the server persists it for you |
| 7 | What is the upgrade story? | Semver, 1.0 LTS until 2.0, deprecations kept through 1.x (2.4), but a very fast cadence and occasional minor-release floors (2.3) |
| 8 | What is the dependency cost? | 39 installed packages for langchain alone, transitive ones included (3.2); LangChain Inc maintains the core packages |
| 9 | Does it match your providers? | First-party packages for OpenAI and Anthropic (primary), plus Gemini and OpenRouter (optional); many more in the catalogue (3.5) |
| 10 | Does it match your team? | The graph mental model (state, nodes, edges) is the one new idea; create_agent hides it until you need it |
7.6 How the rest of this module maps onto the ecosystem#
| Lesson | Ecosystem piece it teaches |
|---|---|
| 08F.5 Chat Models, Messages and Content Blocks | langchain-core plus provider packages: init_chat_model, messages, content blocks |
| 08F.6 Prompts, Parsers and Structured Output | langchain-core prompts and parsers; structured output strategies |
| 08F.7 Runnables and LCEL | The Runnable protocol and the pipe operator |
08F.8 Tools and create_agent |
langchain agents, tools and middleware; MCP |
| 08F.9 RAG with LangChain | Loaders, splitters, embeddings, vector stores and retrievers across packages |
| 08F.10 to 08F.14 | langgraph: graphs, persistence and memory, human-in-the-loop, subgraphs and multi-agent, the Functional API and streaming |
| 11A.5 LangSmith, Testing and Deployment | langsmith, Studio and Agent Server |
| 08F.15 Patterns, Pitfalls and Migration | Production patterns, anti-patterns and the migration guides, in depth |
| 08F.17 Finish Learning from the Official Docs | The official documentation, as the place to finish learning |
7.7 A note on JavaScript#
This module is Python only. For orientation, the JavaScript packages mirror the structure: langchain (1.6.6 on npm), @langchain/core (1.4.1), @langchain/langgraph (1.7.4), provider packages such as @langchain/openai and @langchain/anthropic, @langchain/textsplitters, and @langchain/mcp-adapters (2.0.3, still a live package in JavaScript, unlike Python where MCP moved into langchain). The repositories are langchain-ai/langchainjs and deepagentsjs, and the docs have a parallel docs.langchain.com/oss/javascript/ tree. Versions are from the npm registry on 14 November 2026, and are different from the Python versions, so never assume that a Python version number applies to the JavaScript package of the same name.
Common misconceptions#
| Misconception | Reality |
|---|---|
| "LangChain, LangGraph and LangSmith are three names for one thing." | Three layers: LangChain is the agent framework (langchain), LangGraph is the runtime (langgraph), LangSmith is a hosted platform. The first two are MIT-licensed packages; LangSmith is a service (Part 1). |
| "LangChain is obsolete; use LangGraph." | LangChain 1.x is built on LangGraph. create_agent returns a compiled LangGraph graph, and most systems use both (7.2). |
"pip install langchain gives me everything, including OpenAI." |
It installs langchain-core, langgraph and pydantic (and their dependencies). No provider package, no text splitters, no community or classic code (3.2). |
| "The old tutorial's code is just a few versions behind." | Whole modules are gone from langchain 1.x (langchain.chains, .memory, .llms, .prompts, .schema, .text_splitter...). The imports fail (4.2). |
"langchain-classic is the safe way to keep using old code." |
It is a migration bridge. Its deprecated classes carry a removal date of 2.0.0 (4.3). |
"create_react_agent is create_react_agent." |
Two different functions share the name: the text-ReAct factory for AgentExecutor (now in langchain_classic) and the deprecated LangGraph prebuilt (4.4). |
| "LangGraph Server, LangSmith Deployment and Agent Server are three products." | One runtime renamed twice. The packages and the Docker image kept the langgraph name (1.7). |
| "I need LangSmith to use LangChain." | No. Tracing is optional and framework-agnostic, and the SDK is just a package. Turn it on with environment variables when you want it (5.7). |
"Deep Agents replaces create_agent." |
It is a layer on top of it: a pre-1.0 harness with planning, files and subagents. Use it for long multi-step work, not as a default (6.1). |
| "1.0 means nothing will break." | The promise is that 1.x keeps working, with deprecations lasting the whole major version. Minor releases still raise the Python floor, change beta features and change defaults in provider packages (2.4). |
| "The docs are the source of truth for versions." | When docs and installed packages disagree (Python floor, langgraph.__version__), the package wins (4.8). |
"langchain-community is where the long tail of integrations lives." |
It was, until it was sunset on 22 May 2026; the repository is archived and 0.4.2 is the last release. langchain-experimental is archived too. Use a dedicated package, your own code or MCP (3.7). |
| "A framework is always worth it for an agent." | A working loop of your own, or a single structured-output call, can be the better choice. Count what you would really write (7.4). |
Key takeaways#
- Four layers, one direction of dependency. LangChain (framework:
create_agent, middleware, models, tools) is built on LangGraph (runtime: state, persistence, interrupts, streaming), which shareslangchain-core. Deep Agents (harness) sits on top; LangSmith (platform) and Agent Server (deployment) sit beside. - Package, repository and product names differ.
langchainis only the agent-focused package;libs/langchainin the monorepo islangchain-classic; "LangGraph Server" is now LangSmith Agent Server. Use the naming map to decode any article. uv add langchaininstalls LangGraph andlangchain-core, but no provider. Addlangchain-openai,langchain-anthropic,langchain-google-genaiorlangchain-openrouterfor your provider, andlangchain-text-splittersfor splitters. A bare install oflangchainis 39 packages against 18 for two raw SDKs.- Python 3.11 or newer. The docs still say 3.10;
langchain1.5 andlangchain-core1.8 require 3.11. Setrequires-pythondeliberately, because a loose bound quietly lowers your dependency floors. - The 1.0 line is the stable one. Semver, LTS until 2.0, deprecations kept through 1.x. The fast cadence, beta features, provider packages and pre-1.0
deepagentsare where surprises live: commituv.lock, upgrade on a branch, read the changelog, test with fake models. - Date old tutorials by their vocabulary and translate them.
LLMChainbecomesprompt | model;AgentExecutorand the LangGraphcreate_react_agentbecomecreate_agent; memory classes become a checkpointer and theStore;langchain-communityimports (the package is sunset) become partner packages, your own code or MCP;langchain-mcp-adaptersbecomeslangchain.mcp. langchain-classicis a bridge, not a destination. Use it to read or rescue old code, then port.- You can verify the architecture yourself with no key. A LangGraph graph with a plain-Python node, a fake chat model, and a
create_agentagent whose type isCompiledStateGraphall ran in this lesson. - Choose by what you need to control. One call: no framework. A tool-using agent:
create_agent. Pauses, branching, crash recovery: LangGraph, with agents as nodes. Long multi-step work: Deep Agents. An HTTP API with threads and cron: Agent Server or your own service. Already have a good loop: keep it, add tracing. - Trust the installed package over the page. Verify versions with
importlib.metadata, notlanggraph.__version__.
Terms introduced in this lesson#
| Term | One-line definition |
|---|---|
| LangChain | The agent framework from LangChain Inc: create_agent, middleware, models, messages and tools, in the langchain package (1.x) |
| LangGraph | The low-level agent runtime and orchestration library (langgraph): state graphs with durable execution, persistence, interrupts and streaming |
| LangSmith | LangChain Inc's hosted platform for tracing, evaluation, prompts and deployment, usable with any framework |
| Deep Agents | A pre-1.0 agent harness (deepagents) with planning, a virtual filesystem, subagents and context management, built on LangChain and LangGraph |
| LangSmith Agent Server | The deployment runtime exposing assistants, threads and runs over HTTP; formerly LangGraph Server and LangSmith Deployment |
| Agent harness | Everything around a model that makes it an agent: the loop, tools, context handling, prompts and memory ("Agent = Model + Harness") |
langchain-core |
The base package of interfaces and protocols (messages, Runnables, prompts, parsers, tools, model and vector-store interfaces) that all other packages build on |
| Partner package | A provider integration package maintained as its own PyPI package, such as langchain-openai or langchain-anthropic |
langchain-community |
The package of community-contributed integrations, sunset on 22 May 2026 and archived (0.4.2 is the last release); use a dedicated partner package, your own code or MCP instead |
langchain-classic |
The package holding everything removed from langchain in 1.0 (legacy chains, AgentExecutor, memory classes, the hub), kept for migration |
| Namespace reduction | The 1.0 change that cut langchain down to the agent-focused modules (agents, messages, tools, chat_models, embeddings) |
create_agent |
The single agent factory of LangChain 1.x; it returns a compiled LangGraph graph and replaces AgentExecutor and the LangGraph prebuilt create_react_agent |
| LTS (long-term support) | The commitment that LangChain 1.0 and LangGraph 1.0 stay active until 2.0 and are then maintained for at least a year |
| Stability label | The annotation on an API: stable (no prefix), beta, alpha, deprecated or internal (leading underscore) |
| Lockfile | uv.lock, the file that records the exact version of every dependency so installs are reproducible; commit it |
| Transitive dependency | A package that one of your dependencies needs, installed although you never named it |
| Bridge import | A langchain_classic import used temporarily to keep pre-1.0 code running while you migrate |
Exercises#
- Reproduce the weight measurement. Create three throwaway projects with
uv init <name> --bare --python 3.13: (a)uv add openai anthropic python-dotenv, (b)uv add langchain, (c) the full lab project of 5.2. In each, runuv pip list --format freeze | wc -l(the--format freezeform has no header lines, so it counts packages only). Do you get 18, 39 and 62 (or close to them, given newer releases and your platform)? Then compare with the entries in each project'suv.lockand explain why that count is higher. Runuv tree --depth 1in (c) and explain which packages each top-level line brought in. - Verify your install. Run
check_setup.pyfrom 5.4 and the three keyless programs of 5.5. Then tryimport langgraph; print(langgraph.__version__)and explain the result. - Import audit. Write a script that tries each pre-1.0 import in the table of 4.2 and prints "module is gone", "module exists, name is gone" or "OK" for each, and run it on your install.
- Date and translate. Here is a snippet from a blog post. Date it using 4.5; list every import that fails on
langchain1.5; and rewrite it with the current API (a checkpointer and athread_idreplace the memory class, so describe that part in prose until 08F.11).
from langchain.chains import LLMChain
from langchain.memory import ConversationBufferMemory
from langchain.prompts import PromptTemplate
from langchain_community.chat_models import ChatOpenAI
memory = ConversationBufferMemory()
prompt = PromptTemplate.from_template("History: {history}\nUser: {input}\nReply:")
chain = LLMChain(llm=ChatOpenAI(model="gpt-4o"), prompt=prompt, memory=memory)
print(chain.run("My order A-1042 is late."))- Keyless tests. Write
tests/test_ecosystem.pywith three tests: the hello graph appends exactly one AI message; acreate_agentagent on aGenericFakeChatModelreplies with the scripted text; and the agent's graph has a node calledmodel. Run them withuv run pytest -q. - Package map drill. For each task, name the packages you would add to a fresh project: (a) a tool-using agent on Anthropic Claude; (b) an agent that reads an MCP server's tools; (c) a RAG prototype that splits PDFs; (d) a local agent server; (e) running a 2024
AgentExecutortutorial unchanged. Then say which of them you would not add on a team project and why, and which other package on the list is sunset. - Choose. For each scenario, pick LangChain, LangGraph, both, Deep Agents or neither, justify it with 7.1, and name one risk of your choice: (a) a nightly job that classifies 5,000 support tickets into six categories; (b) a refund workflow where a human must approve amounts over a limit and the run must survive a deploy; (c) a research assistant that spends 20 minutes reading sources and drafting a report; (d) a customer-facing chat agent with three read-only tools and a budget of five model calls.
- Docs versus package. Check which of the six disagreements in 4.8 still hold on the day you read this. Record the installed versions and the date, and note any that changed.
Answers and hints
- Counts will drift upwards over time as packages add dependencies, and differ by a few across platforms, so "close to" is the right standard. The
uv.lockcount is higher because the lockfile also lists your own project and packages that only some platforms install (a Windows-only terminal-colour helper, for example). In (c),langchainbringslangchain-core,langgraphandpydantic; the three provider packages each bring their provider SDK (openai,anthropic,google-genai) andlangchain-core;python-dotenvstands alone. Useuv treewithout--depthto see the second level. langgraph.__version__raisesAttributeErroronlanggraph1.2.22 even though the versioning page suggests it exists. Useimportlib.metadata.version("langgraph"). If a newerlanggraphhas added the attribute by the time you read this, say so: that is exactly the exercise 8 habit.- A script that gives the real answers of this lesson:
# import_audit.py: try each pre-1.0 import and report what a 1.x install does with it
import importlib
OLD_IMPORTS = [
("langchain.chains", "LLMChain"),
("langchain.agents", "AgentExecutor"),
("langchain.memory", "ConversationBufferMemory"),
("langchain.llms", "OpenAI"),
("langchain.chat_models", "ChatOpenAI"),
("langchain.prompts", "ChatPromptTemplate"),
("langchain.schema", "HumanMessage"),
("langchain.text_splitter", "RecursiveCharacterTextSplitter"),
("langchain.agents", "create_agent"), # a current import, for contrast
]
for module_name, attribute in OLD_IMPORTS:
try:
module = importlib.import_module(module_name)
getattr(module, attribute)
status = "OK"
except ModuleNotFoundError:
status = "module is gone"
except AttributeError:
status = "module exists, name is gone"
print(f"from {module_name} import {attribute}: {status}")from langchain.chains import LLMChain: module is gone
from langchain.agents import AgentExecutor: module exists, name is gone
from langchain.memory import ConversationBufferMemory: module is gone
from langchain.llms import OpenAI: module is gone
from langchain.chat_models import ChatOpenAI: module exists, name is gone
from langchain.prompts import ChatPromptTemplate: module is gone
from langchain.schema import HumanMessage: module is gone
from langchain.text_splitter import RecursiveCharacterTextSplitter: module is gone
from langchain.agents import create_agent: OK- The snippet is from the 2023 chain era (
LLMChain,.run, a memory class,langchain_community.chat_models) and uses a retired model id. Failing imports:langchain.chains,langchain.memoryandlangchain.prompts(modules gone);langchain_community.chat_models.ChatOpenAIimports only iflangchain-communityis installed, is an old copy of the partner class, and comes from a sunset package. Current shape: build the model withinit_chat_model("openai:gpt-6-luna")(orChatOpenAIfromlangchain_openai), write the prompt as aChatPromptTemplateor just a system prompt, usecreate_agent(with no tools if you only need a chat) and give the conversation memory by passing a checkpointer and athread_id. Replace the model id from the provider's page. - One passing solution, run for real on 14 November 2026 (
3 passed in 0.15s):
# tests/test_ecosystem.py: keyless tests for a graph and an agent
from langchain.agents import create_agent
from langchain_core.language_models.fake_chat_models import GenericFakeChatModel
from langchain_core.messages import AIMessage
from langgraph.graph import END, START, MessagesState, StateGraph
def build_graph():
def mock_llm(state: MessagesState) -> dict:
return {"messages": [{"role": "ai", "content": "hello world"}]}
builder = StateGraph(MessagesState)
builder.add_node(mock_llm)
builder.add_edge(START, "mock_llm")
builder.add_edge("mock_llm", END)
return builder.compile()
def test_graph_appends_one_ai_message():
result = build_graph().invoke({"messages": [{"role": "user", "content": "hi"}]})
assert [m.type for m in result["messages"]] == ["human", "ai"]
assert result["messages"][-1].content == "hello world"
def test_agent_replies_with_the_scripted_text():
fake = GenericFakeChatModel(messages=iter([AIMessage(content="Pong")]))
agent = create_agent(model=fake, system_prompt="Be terse.")
result = agent.invoke({"messages": [{"role": "user", "content": "ping"}]})
assert result["messages"][-1].content == "Pong"
def test_agent_is_a_graph_with_a_model_node():
fake = GenericFakeChatModel(messages=iter([]))
agent = create_agent(model=fake)
assert "model" in agent.get_graph().nodes- (a)
langchain,langchain-anthropic,python-dotenv(for Gemini, the optional provider, swap inlangchain-google-genai). (b)"langchain[mcp]"plus a provider package (notlangchain-mcp-adapters, whichlangchain.mcpreplaced). (c)langchain,langchain-text-splitters, a PDF loader package or a parser from Module 05, an embeddings package and a vector-store package (08F.9). (d)"langgraph-cli[inmem]". (e)langchain-classic(plus the provider package). On a team project you would not add (e) as a permanent dependency (it is a bridge with a removal date). The sunset packages arelangchain-communityandlangchain-experimental: you would add neither, because both are archived; (c) in particular now means a dedicated loader package or your own loader, notlangchain-community. (If an old tutorial for (e) imports fromlangchain_community, that part needs porting, not installing.) - (a) Neither, or at most
init_chat_modelwith structured output: a fixed pipeline with no loop; the risk of a framework here is paying 39 packages for nothing. (b) LangGraph (aStateGraph, a checkpointer andinterrupt), possibly withcreate_agentas a node for the conversational part; the risk is that you now own the graph, so you need tests and a persistence store you can operate. (c) Deep Agents, orcreate_agentwith planning and file tools; the risk is a pre-1.0 package and cost from long context, so set budgets and read the changelog. (d)create_agentwithModelCallLimitMiddleware(five calls) and a checkpointer if you need threads; the risk is relying on the default recursion limit, which is far too high to bound cost. - The exercise has no fixed answer by design. The pattern to follow: write down
uv pip listversions, run the commands from the table, and note differences, for example a newerlanggraphexposing__version__, a docs page corrected to 3.11, or a changedgoogle-genaiprefix handling.
Check yourself#
- In one sentence each, what are LangChain, LangGraph, LangSmith, Deep Agents and LangSmith Agent Server?LangChain: the agent framework (
create_agent, middleware, models, tools). LangGraph: the low-level runtime for stateful, durable agents (graphs, persistence, interrupts, streaming). LangSmith: the hosted platform for tracing, evaluation, prompts and deployment. Deep Agents: a pre-1.0 batteries-included harness with planning, a virtual filesystem and subagents. Agent Server: the deployment runtime that serves graphs as an API with assistants, threads and runs. - What does the official docs' formula "Agent = Model + Harness" mean, and which products sit at the framework, runtime and harness layers?A model plus everything around it (the loop, tools, context handling, prompts, memory) is an agent. LangChain is the framework layer, LangGraph is the runtime layer, and Deep Agents is a more opinionated harness on top of both. (
create_agentis a minimal harness inside the framework: you choose the tools, prompts and middleware; Deep Agents ships those choices already made.) - Which direction do the dependencies run between LangChain and LangGraph, and what does that imply about learning order?LangChain 1.x is built on LangGraph; LangGraph does not require LangChain. So you can learn LangChain first without knowing LangGraph (the order of this module: 08F.5 to 08F.9, then 08F.10 onwards), but
create_agentalready is a LangGraph graph, which pays off when you need persistence or interrupts. - What three names has the deployment server had, and which pieces still carry the old name?LangGraph Platform or LangGraph Server, then LangSmith Deployment, now LangSmith Agent Server. The PyPI packages (
langgraph-api,langgraph-cli,langgraph-sdk), the CLI and the Docker image name keep thelanggraphname. - What does
uv add langchaininstall, and what does it not install?It installslangchain,langchain-core,langgraph(with its checkpoint, prebuilt and SDK packages),pydantic,langsmithand a few more: 39 installed packages in total (counting transitive ones, on macOS with Python 3.13). It does not install a provider package,langchain-text-splitters,langchain-community,langchain-classicor any vector store. - Why do a bare install of
langchainand an install ofopenaiplusanthropicdiffer so much in package count, and why should that matter to you?The framework brings the graph runtime, the message model and tracing support, which raw SDKs do not have. It matters because each extra package is a version-conflict and supply-chain surface; you should know the cost when you choose a framework and when you review lockfile diffs. - Which Python version do you need, and what is the disagreement between the docs and the package metadata?3.11 or newer. The install page and v1 migration guide say 3.10+, but
langchain1.5.0 andlangchain-core1.8.0 declare>=3.11and the changelog says 3.10 support was dropped.langgraph1.2.22 still allows 3.10. Package metadata is what the installer enforces. - What does "LangChain 1.0 is LTS" promise, and what does it not promise?It promises that 1.0 stays active until 2.0 and is maintained for at least a year afterwards, with deprecated features kept working through the whole 1.x series. It does not promise that nothing changes: minors still add features, raise the Python floor, change defaults in provider packages and alter beta features.
- A tutorial does
from langchain.chains import LLMChain. What happens onlangchain1.5, what is the bridge, and what is the real fix?ModuleNotFoundError: No module named 'langchain.chains'. The bridge isfrom langchain_classic.chains import LLMChainafter installinglangchain-classic. The real fix is to port toprompt | model. - Which two different functions are called
create_react_agent, and what replaces each?The old LangChain text-ReAct factory used withAgentExecutor(nowlangchain_classic.agents.create_react_agent), and the LangGraph prebuiltlanggraph.prebuilt.create_react_agent. Both are replaced bylangchain.agents.create_agent. - How do you correctly check the installed version of
langgraph, and why notlanggraph.__version__?importlib.metadata.version("langgraph"). The attributelanggraph.__version__does not exist inlanggraph1.2.22, although the versioning page suggests it (importing it raisesAttributeError).langchain.__version__andlangchain_core.__version__do exist. - What does
create_agentreturn, and how did you verify it without an API key?A compiled LangGraph graph (CompiledStateGraphfromlanggraph.graph.state). Using aGenericFakeChatModelas the model, printing the type of the returned object and its graph nodes (__start__,model,__end__) proves it with no key. - When would you choose each of: no framework,
create_agent, LangGraph, both, Deep Agents?No framework: one call, a short fixed pipeline, or a loop you already own.create_agent: a tool-using agent with the standard loop. LangGraph: explicit state, branches, approvals, crash recovery, schedules. Both: a deterministic skeleton with agent steps. Deep Agents: long multi-step work that benefits from planning, a filesystem and subagents. - Why is the
.envfile never committed, and what do you commit instead?It holds secrets, and committing it publishes them to everyone with repository access (and to the history forever). Commit.env.examplewith variable names only, and add.envto.gitignorebefore the first commit. - Why is
ModuleNotFoundError: No module named 'fastmcp'an install problem, not a code problem?langchain.mcpimportsfastmcp, which comes from themcpextra. Your code is right; the environment lacks the extra. The fix isuv add "langchain[mcp]". - A tutorial imports a document loader from
langchain_community. What is the status of that package, and what are your options?langchain-communitywas sunset on 22 May 2026 and its repository archived on 19 June 2026 (0.4.2 is the last release);langchain-experimentalis archived too. The import still works, but nothing is maintained. Options in order: a dedicated package from the integrations catalogue, your own loader (10 to 30 lines), or the capability over MCP; if you must keep the import for now, rely on the lockfile and schedule the port.
Further resources#
Official sources only. Where the official docs are more complete than this lesson (and for integrations they always are), read them: 08F.17 is the closing lesson that says how.
- Orientation: LangChain overview, install, quickstart, philosophy and history, runtimes, frameworks and harnesses, providers and models, component architecture
- LangGraph and Deep Agents: LangGraph overview, Deep Agents overview
- Sunset packages:
langchain-communitysunset announcement (issue 674),langchain-experimentalsunset announcement (issue 87) - Releases and migration: LangChain v1 release notes, LangGraph v1 release notes, migrate to LangChain v1, migrate to LangGraph v1, from
langchain-mcp-adapters, fromlanggraph-supervisor, changelog - Policy: versioning, release policy
- Integrations: providers overview
- LangSmith and deployment: observability, deployment (Agent Server), local server
- API reference: reference.langchain.com/python
- Source and packages:
langchain-ai/langchain,langchain-ai/langgraph,langchain-ai/deepagents,langchain-ai/docs; PyPI:langchain,langchain-core,langchain-classic,langgraph - Courses: LangChain Academy
- Tooling:
uvprojects guide - In this course: 08F.1 Agent Frameworks and SDKs for the cross-framework comparison, 03.1 Part 4 for project setup, 03.11, 13.9 for dependency hygiene
← 08F.3: Claude Agent SDK | Module 08F overview | 08F.5: Chat Models, Messages and Content Blocks →