LangChain

About this knowledge base

This knowledge base has two layers. Start with beginner-route/ to build an end-to-end engineering path from components, LCEL, models, and messages through tools, retrieval, state, LangGraph, and testing. Then consult the official-documentation translations and case studies as needed. Framework APIs change quickly, so the learning priority is stable input/output contracts and control boundaries—not memorizing an import path from one release.

Existing files form a reference layer of official documentation retrieved on fixed dates; beginner-route/ is the new explanatory layer for learners starting from zero. Keeping the layers separate preserves provenance and licensing while letting dependency upgrades focus review on executable boundaries.

Current version baseline

At the 2026-07-22 review, PyPI listed langchain 1.3.14 (2026-07-16), langgraph 1.2.9 (2026-07-10), and langchain-core 1.5.0 (2026-07-21). These figures describe this material snapshot only; they do not mean the three packages can be combined arbitrarily outside dependency resolution. New projects should install in an isolated environment, generate a lockfile, and run tests. The LCEL, retrieval, and create_agent exercises that pin langchain-core==1.4.9 retain their verified teaching contract and must not be replaced blindly merely because the latest core release changed. The existing official translations were retrieved on 2026-05-07 and may predate the current API, so treat them as a reference layer rather than copy-paste instructions that need no review.

A frozen reference layer is not a directly executable tutorial

01-Learn.md and the existing translations under numbered sections 01–06 retain their original sources, retrieval dates, and licenses for conceptual orientation and historical comparison. Complete beginner-route/ first. Before copying an import, model ID, provider parameter, or production-deployment pattern from those pages, return to the linked current official documentation and the project lockfile. In particular, never treat illustrative RAG, SQL, Deep Agents, or multi-agent reference code as proof that authorization, evaluation, or production validation is complete.

Bedrock model lifecycle

The legacy/retirement-migration window includes the old reference-layer ID anthropic.claude-3-5-sonnet-20240620-v1:0; examples now use anthropic.claude-sonnet-4-6 from the current AWS model card. Bedrock model IDs, regional availability, and bedrock_converse support must still be verified in the target account against the AWS model catalog. Do not treat IDs in these notes as permanent guarantees.

Position in the overall learning route

This knowledge base belongs to the Framework Practice stage. The foundation LCEL and model units require only the Python, HTTP/JSON, and LLM API concepts listed below. When moving into tools, RAG, or state graphs, add Tool Calling, retrieval, and Agent-state knowledge as appropriate. This is a recommended module-by-module progression, not a claim that LangChain or any upstream full course is a hard prerequisite for every Agent or RAG role. Move down to LangGraph only when a workflow actually needs explicit branching, persistent state, pause-and-resume behavior, or fine-grained orchestration.

Learning objectives

  • Understand the responsibility boundaries among LangChain, LangGraph, langchain-core Runnables (LCEL), and Deep Agents.
  • Compose deterministic steps with LCEL and decide when ordinary Python, a Runnable, an Agent, or a state graph is appropriate.
  • Describe a minimal Agent loop using messages, models, tools, and structured output.
  • Connect a retriever to generation while distinguishing short-term state from long-term memory.
  • Recognize when LangGraph checkpoints, interrupts, and explicit state graphs are needed.
  • Design boundaries for tool permissions, failure recovery, offline evaluation, and production observability.

Prerequisites

  • Python functions, type hints, virtual environments, and exception handling.
  • Basic HTTP/JSON and LLM API concepts; prior LangChain experience is not required.
  • When using real models, choose a provider and inject credentials through environment variables; this route does not include real secrets.
  1. Component Map, Environment, and a Minimal LCEL Invocation: establish product, version, and composition boundaries.
  2. Models, Messages, Prompts, and Structured Output: master input/output contracts.
  3. Tools and Agent Loops: understand how a model requests external actions.
  4. Retrieval and RAG Components: connect private knowledge to an application.
  5. Memory, State, and Persistence: store short- and long-term information correctly.
  6. LangGraph Boundaries, Approval, Recovery, and Evaluation: move into explicit orchestration.
  7. Project: Offline Tool-Agent Skeleton: verify the core loop without dependencies or keys.
  8. Project: Keyless `create_agent` Runtime Contract: verify messages, tool results, and fail-closed boundaries in a real LangChain harness.
  9. Project: LangGraph Recoverable Approval Flow: verify SQLite checkpoints, interrupts, and cross-process recovery in a real runtime.
  10. Testing, Evaluation, and Upgrade Checklist: turn a prototype into a regression-tested engineering asset.

01-Conceptual Overviews

02-LangChain

03-LangGraph

04-Multi-agent

05-Deep Agents

06-Additional Resources

Hands-on practice and project entry points

  • Every beginner note includes a design exercise; the integrated entry point is the offline tool-agent skeleton.
  • beginner-route/examples/offline_agent_loop.py uses only the Python standard library to simulate the loop “model proposes a tool call → executor validates it → tool returns a result → model produces a final answer.”
  • beginner-route/examples/lcel_no_key.py is an LCEL composition example that needs no model key. The base environment does not keep langchain-core installed, but the example was run successfully in isolation with langchain-core==1.4.9.
  • beginner-route/examples/test_offline_agent_loop.py runs deterministic, network-free unit tests for the offline loop.
  • beginner-route/examples/retrieval_layer_b/ pins langchain-core==1.4.9 and NumPy 2.4.6 compatible with Python 3.11. Its 17 tests cover stable IDs, metadata, tenant filtering before retrieval, InMemory raw cosine scores, and Retriever invoke/batch; the transparent teaching embedding does not prove real semantic-retrieval quality.
  • beginner-route/examples/langchain_layer_b/ runs create_agent with pinned langchain==1.3.14, langchain-core==1.4.9, and langgraph==1.2.9. Its eight tests cover success, unknown tools, strict-schema rejection, and fail-closed version drift in normal, -O, -W error, and -O -W error modes. Its scripted model intentionally bypasses provider-schema conversion and cannot replace a real provider smoke test.
  • beginner-route/examples/langgraph_layer_b/ runs langgraph==1.2.9 directly with a SQLite checkpointer. Its ten tests cover cross-process interrupt/resume, thread_id normalization, version/state contract guards, and node replay. It requires no model credentials and does not promise exactly-once external side effects.
  • Examples that need real models must still be installed and pinned in a separate venv; without provider credentials, do not claim the model has run end to end.

Mastery criteria

  • Explain the high-level scenarios suited to create_agent and when to use LangGraph instead.
  • Distinguish a real LangChain runtime contract from evidence about provider schemas, model quality, authorization, and network integration.
  • Explain the contracts for LCEL’s RunnableSequence, RunnableParallel, and invoke/batch/stream, without treating legacy LLMChain tutorials as the default v1 entry point.
  • Define clear input, error, and permission boundaries for a tool.
  • Distinguish message history, run state, checkpoints, and long-term memory.
  • Design a minimal application with retrieval, citations, human approval, recovery, and offline evaluation.

Relationship to other knowledge bases

  • Agentic Design Patterns answers pattern-selection questions first; this course then maps patterns onto LangChain/LangGraph components.
  • Tool Calling (including Function Calling) explains protocol and executor boundaries; this course shows how they map to @tool and an Agent loop.
  • Retrieval-Augmented Generation explains retrieval quality and generation evaluation; this course focuses on component assembly rather than replacing RAG fundamentals.
  • CrewAI emphasizes Crew role collaboration and Flow event processing; do not select between them merely by comparing example length.
  • RAG, Tool Calling, and evaluation knowledge bases provide independent fundamentals; a framework does not replace data quality, permissions, or test design.

Primary references