跳到主要内容
本指南概述了 LangGraph v1 中的更改以及如何从以前的版本进行迁移。有关更改的高级概述,请参阅新功能页面。 升级方法:
pip install -U langgraph langchain-core

更改摘要

LangGraph v1 大体上向后兼容以前的版本。主要变化是弃用 create_react_agent,转而使用 LangChain 新的 create_agent 函数。

弃用

下表列出了 LangGraph v1 中所有已弃用的项目
已弃用项目替代方案
create_react_agentlangchain.agents.create_agent
AgentStatelangchain.agents.AgentState
AgentStatePydanticlangchain.agents.AgentState(不再使用 pydantic 状态)
AgentStateWithStructuredResponselangchain.agents.AgentState
AgentStateWithStructuredResponsePydanticlangchain.agents.AgentState(不再使用 pydantic 状态)
HumanInterruptConfiglangchain.agents.middleware.human_in_the_loop.InterruptOnConfig
ActionRequestlangchain.agents.middleware.human_in_the_loop.InterruptOnConfig
HumanInterruptlangchain.agents.middleware.human_in_the_loop.HITLRequest
ValidationNode工具会自动验证 create_agent 的输入
MessageGraph带有 messages 键的 StateGraph,如 create_agent 所提供

create_react_agentcreate_agent

LangGraph v1 弃用了 create_react_agent 预构建。请使用 LangChain 的 create_agent,它运行在 LangGraph 上并增加了灵活的中间件系统。 有关详细信息,请参阅 LangChain v1 文档:
from langchain.agents import create_agent

agent = create_agent(  
    model,
    tools,
    system_prompt="You are a helpful assistant.",
)

重大变更

停止支持 Python 3.9

所有 LangChain 包现在都要求 Python 3.10 或更高版本。Python 3.9 已于 2025 年 10 月停止维护
以编程方式连接这些文档到 Claude、VSCode 等,通过 MCP 获取实时答案。
© . This site is unofficial and not affiliated with LangChain, Inc.