Agent framework on the LangGraph runtime · create_agent · middleware · content blocks · verified against LangChain 1.x (2026)

LangChain cheat sheet

LangChain 1.x is a focused, high-level API for building agents. Its centerpiece is create_agent() — a production agent loop that runs on the LangGraph runtime underneath, so you get durable execution, streaming, and checkpointed memory for free. Customize every step with middleware, get one unified content_blocks view across providers, and reach for init_chat_model to swap models by string. Legacy chains/retrievers now live in langchain-classic. Targets langchain / langchain-core 1.x, Python 3.10–3.14.

agents & core models & messages tools & structured output middleware & runtime streaming / memory / compose gotcha / migration most common

Verified 2026-08-30 against the official docs at docs.langchain.com and reference.langchain.com (LangChain / langchain-core 1.x; latest langchain 1.3.18). LangChain 1.0 GA shipped Oct 2025; create_agent executes on the LangGraph 1.x runtime.

Outline

Learn create_agent first — models, tools, structured output, and middleware all plug into it. Streaming, memory, and LCEL composition sit on the same LangGraph runtime.

Getting started

  1. 1Install & imports — packages, keys
  2. 2create_agent — the core — build & run

Models & messages

  1. 3init_chat_model & providers
  2. 4Messages & content_blocks

Tools & output

  1. 5Tools with @tool
  2. 6Structured output

Middleware & runtime

  1. 7Middleware & hooks
  2. 8Prebuilt middleware
  3. 9Runtime & context

Streaming / memory / compose

  1. 10Invoke & stream
  2. 11Memory & checkpointer
  3. 12LCEL, Runnables & prompts
  4. 13Retrieval / RAG

Ecosystem

  1. 14LangGraph & LangSmith
  2. 15v1 migration & classic

Getting Started

Install the meta-package plus a provider integration, then build your first agent.

1Install & importspip / keys
2create_agent — the corethe whole loop

Models & Messages

Pick a model by string, and read modern LLM output through one content-block schema.

3init_chat_model & providersswap by string
4Messages & content_blocksunified I/O

Tools & Structured Output

Turn any Python function into a tool; force the model to answer in your schema.

5Tools with @toolgive it hands
6Structured outputtyped answers

Middleware & Runtime

Middleware is the v1 way to customize the agent loop — hook any step without dropping to raw graph code.

7Middleware & hookscontrol the loop
8Prebuilt middlewarebatteries included
9Runtime & contexttyped injection

Streaming, Memory & Composition

The LangGraph runtime gives every agent streaming, durable memory, and LCEL composition.

10Invoke & streamsync / async
11Memory & checkpointerthreads
12LCEL, Runnables & promptscompose
13Retrieval / RAGground it

Ecosystem & Migration

Where LangChain sits in the stack, and what moved in the 1.0 cutover.

14LangGraph & LangSmiththe stack
15v1 migration & classic0.x → 1.x

Worth memorizing

create_agentmodel + tools + system_prompt + middleware
statedict with a "messages" list; answer = last msg
init_chat_model"provider:model" — swap backends by string
content_blocksunified text/reasoning/tool_call/image view
@tooldocstring = description, type hints = schema
response_formatPydantic → result["structured_response"]
middlewarebefore/after_model, wrap_model_call hooks
thread_idconfig["configurable"] + a checkpointer = memory
stream_modevalues / updates / messages / custom
LCELprompt | model | parser (Runnable pipe)
runtimecreate_agent runs on the LangGraph engine
langchain-classichome of legacy chains / retrievers / hub