LangChain/Core Concepts
Intermediate10 min

LangChain v1 Migration Guide

Everything that changed in LangChain v1: create_agent replaces create_react_agent, ToolRuntime replaces InjectedState, middleware replaces hooks, and TypedDict is the only state type.

Quick Reference

  • from langchain.agents import create_agent — replaces create_react_agent from langgraph.prebuilt
  • system_prompt parameter replaces prompt — extract string from SystemMessage objects
  • ToolRuntime replaces InjectedState, InjectedStore, InjectedConfig — one typed parameter
  • State schemas must be TypedDict only — Pydantic and dataclass no longer supported
  • .text is a property, not a method — remove parentheses: message.text not message.text()
  • Legacy code available in langchain-classic package

Breaking Changes at a Glance

Before (v0.x)After (v1.0)Migration
from langgraph.prebuilt import create_react_agentfrom langchain.agents import create_agentChange import
prompt=SystemMessage(...)system_prompt='...'Extract string or pass SystemMessage
InjectedState, InjectedStore, InjectedConfigToolRuntime[Context]Single typed parameter
config['configurable']['user_id']runtime.context.user_idUse typed context_schema
pre_model_hook / post_model_hookmiddleware=[...]Use AgentMiddleware or decorators
Pydantic / dataclass stateTypedDict onlyConvert to TypedDict subclass of AgentState
.text() method.text propertyRemove parentheses
example= on AIMessageRemovedUse few-shot via messages list
Streaming node name 'agent'Node name 'model'Update stream filters
Output parsers for structured outputProviderStrategy / ToolStrategyUse response_format
Legacy chains (LLMChain, etc.)langchain-classic packagepip install langchain-classic