GEO

DeepAgents是什么?LangChain新一代复杂AI智能体框架深度解析

2026/3/29
DeepAgents是什么?LangChain新一代复杂AI智能体框架深度解析
AI Summary (BLUF)

DeepAgents is LangChain's latest open-source framework designed to simplify the development of complex, multi-step AI agents by providing built-in capabilities for task planning, virtual file systems, and subagent collaboration, enabling developers to build more robust and capable agents with less code.

原文翻译: DeepAgents是LangChain最新推出的开源框架,旨在简化复杂多步骤AI智能体的开发,通过提供任务规划、虚拟文件系统和子智能体协作等内置能力,使开发者能够用更少的代码构建更强大、更可靠的智能体。

近期,LangChain 公司正式发布了 LangChain 1.0 及其配套的 LangGraph 1.0,标志着其通用 Agent 框架已趋于成熟。在此基础上,团队还推出了全新的开源项目 DeepAgents,旨在进一步提升 Agent 在复杂场景下的能力,用更少的代码完成更“深度”的任务。

Recently, LangChain Inc. officially released LangChain 1.0 and its companion LangGraph 1.0, signifying the maturation of its general-purpose Agent framework. Building upon this, the team also introduced a brand-new open-source project, DeepAgents, designed to further enhance Agent capabilities in complex scenarios, enabling the completion of more "deep" tasks with less code.

本文将为你带来 DeepAgents 的深入解读与实战体验。

This article provides an in-depth interpretation and hands-on experience with DeepAgents.

01 DeepAgents:框架定位与能力速览

我们最熟悉的一种 Agent 形态,就是让 LLM 在推理循环中调用工具,并最终完成任务。但在复杂环境下,这类 Agent 往往会显得有些“脆弱”:任务步骤不合理、工具调用错误、上下文不断膨胀、甚至遗忘任务目标;缺乏主动规划步骤、管理中间变量、以及优化上下文的能力。

The most familiar form of an Agent involves an LLM calling tools within a reasoning loop to ultimately complete a task. However, in complex environments, such Agents often appear "fragile": task steps may be unreasonable, tool calls can be erroneous, context continuously expands, and even the task objective can be forgotten. They lack the ability to proactively plan steps, manage intermediate variables, and optimize context.

如果你在 LangChain 生态中开发,可以通过 LangGraph 从底层掌控工作流,例如:什么时候由 AI 决策、什么时候固化流程;使用 ReAct 还是 Plan-then-Execute 等范式 —— 但实现复杂度相对较高。

If you are developing within the LangChain ecosystem, you can use LangGraph to control workflows from the ground up, such as deciding when AI makes decisions versus when processes are solidified, or choosing between paradigms like ReAct or Plan-then-Execute—but the implementation complexity is relatively high.

DeepAgents正是为了解决上述痛点而诞生。其出发点可用一句话概括:让复杂、多步骤、长时间运行的Agent更容易开发与构建。

DeepAgents was born precisely to address these pain points. Its starting point can be summarized in one sentence: Making the development and construction of complex, multi-step, long-running Agents easier.

DeepAgents 是什么?

DeepAgentsLangChain 公司在 LangGraphLangChain 之后推出的第三个独立开源 Agent 框架,与前两者形成清晰分工。

DeepAgents is the third independent open-source Agent framework launched by LangChain Inc. after LangGraph and LangChain, forming a clear division of labor with the previous two.

在最新的LangChain 1.0版本中,这三者开发Agent的定位是:

In the latest LangChain 1.0 version, the positioning of these three for Agent development is as follows:

  • LangGraph:提供持久化与可观测的Runtime,用于构建底层工作流与Agent。

    LangGraph: Provides a persistent and observable Runtime for building underlying workflows and Agents.

  • LangChain:基于 LangGraph 的高层封装,提供更简洁的 Agent 接口(create_agent)与扩展中间件机制。

    LangChain: A high-level encapsulation based on LangGraph, providing a more concise Agent interface (create_agent) and an extensible middleware mechanism.

  • DeepAgents:在 LangChain 的高层接口 + LangGraph 的运行时之上,进一步封装形成“深度 Agent”框架。其核心方法 create_deep_agent,其实就是在 create_agent 之上增加了预置的系列中间件能力。

    DeepAgents: Builds upon LangChain's high-level interface and LangGraph's runtime, further encapsulating to form a "Deep Agent" framework. Its core method, create_deep_agent, essentially adds a preset series of middleware capabilities on top of create_agent.

DeepAgents 增加了哪些能力?

目前在复杂任务Agent领域最成功的有两类:编程智能体与深度研究智能体。DeepAgents也受到这一类应用的启发 — 这些“深度 Agent”通过增加任务规划工具、子Agent、文件系统、详细提示等手段,在实践中突破了传统 Agent 的局限。

Currently, the most successful types of Agents in the complex task domain are programming agents and deep research agents. DeepAgents is also inspired by such applications—these "Deep Agents" break through the limitations of traditional Agents in practice by adding planning tools, subagents, file systems, detailed prompts, and other means.

DeepAgents将这些经验抽象为通用框架,开箱即用地提供任务规划、文件系统、长期记忆、分工协作等能力。

DeepAgents abstracts these experiences into a general framework, providing out-of-the-box capabilities such as task planning, file systems, long-term memory, and division of labor and collaboration.

什么时候选择 DeepAgents

理解了DeepAgents/LangChain/LangGraph三者的分层定位,这个问题可以简单的总结为:当你需要构建复杂的多步骤、长时间运行的Agent;并希望拥有任务规划、文件系统、长期记忆等能力时,考虑DeepAgents 而对于一些简单步骤的任务,直接使用 LangChain 提供的create_agent就已经足够。

Understanding the layered positioning of DeepAgents, LangChain, and LangGraph, this question can be simply summarized as: Consider DeepAgents when you need to build complex, multi-step, long-running Agents and desire capabilities like task planning, file systems, and long-term memory. For some simple step tasks, using LangChain's create_agent directly is sufficient.

通过 DeepAgents,开发者无需从零开始设计长流程 Agent,只需提供自定义工具和任务说明等,就能快速构建一个强大的“深度 Agent”。

With DeepAgents, developers do not need to design long-process Agents from scratch; they can quickly build a powerful "Deep Agent" by simply providing custom tools and task descriptions.

02 实例读懂 DeepAgents:三大核心机制

我们将从构建一个最简单的Agent开始,并逐步细化与丰富其能力。在这个过程中你将可以清晰的看到:DeepAgents是如何在LangGraphLangChain的基础上“添砖加瓦”,以适应更复杂的任务环境。

We will start by building the simplest Agent and gradually refine and enrich its capabilities. In this process, you will clearly see how DeepAgents "adds bricks and tiles" on the foundation of LangGraph and LangChain to adapt to more complex task environments.

首先设计一个简单的场景:构建一个借助于搜索与金融数据接口等工具进行股票分析的Agent。

First, design a simple scenario: Build an Agent that performs stock analysis using tools such as search and financial data interfaces.

初始版本构建

最初这个Agent看上去是一个标准的ReAct范式Agent,唯一区别在于使用create_deep_agent而不是LangChaincreate_agent(前身是LangGraph中的create_react_agent):

Initially, this Agent appears to be a standard ReAct paradigm Agent, with the only difference being the use of create_deep_agent instead of LangChain's create_agent (formerly create_react_agent in LangGraph):

# === 系统指令 ===
SYSTEM_PROMPT = """你是一个股票分析助手。你的任务是帮助用户分析股票,使用 search 工具搜索相关信息。..."""
main_tools = [search] # 通用网络搜索工具
# === 创建 DeepAgent===
agent = create_deep_agent(
    model=f"openai:{OPENAI_MODEL}",
    tools=main_tools,
    system_prompt=SYSTEM_PROMPT,
    debug=True
).with_config({"recursion_limit": RECURSION_LIMIT})

为了更好的观测Agent运行,通过LangGraph命令行来部署与启动:

To better observe the Agent's operation, deploy and start it via the LangGraph command line:

> langgraph dev

然后在出现的LangSmith Studio界面上输入消息:请帮我分析贵州茅台这只股票。

Then, enter the message on the appeared LangSmith Studio interface: Please help me analyze the stock Kweichow Moutai.

你会发现它的运行过程与普通的Agent几乎没有区别。这是正常的,因为在没有触发“深度能力”的情况下,DeepAgents 与普通 Agent 的执行路径相同。

You will find that its operation process is almost indistinguishable from a regular Agent. This is normal because, without triggering "deep capabilities," DeepAgents follows the same execution path as a regular Agent.

现在我们来触发DeepAgent的第一个特性:任务规划。

Now, let's trigger DeepAgent's first feature: task planning.

任务规划:Planning Tool

单纯依赖LLM完成复杂任务的长期规划与执行很容易发生偏离。各大模型厂商推出的“深度 Agent”(如 OpenAI Deep Research、Claude Code)背后除了训练特殊的Agent推理模型外,都采用了类似的策略:在执行前先列步骤、做计划,然后逐一跟踪执行;并在必要时做调整。

Relying solely on LLMs for long-term planning and execution of complex tasks is prone to deviation. The "Deep Agents" launched by major model vendors (e.g., OpenAI Deep Research, Claude Code) employ a similar strategy behind the scenes, besides training specialized Agent reasoning models: List steps and make plans before execution, then track and execute them one by one, making adjustments when necessary.

DeepAgents 中的任务规划能力是通过一个内置工具 write_todos 来实现的。它会在以下条件下触发:

The task planning capability in DeepAgents is implemented through a built-in tool called write_todos. It triggers under the following conditions:

  • 任务目标比较复杂,特别是涉及较多的步骤

    The task objective is relatively complex, especially involving many steps.

  • 用户明确提示要求LLM先规划执行

    The user explicitly prompts the LLM to plan first before execution.

  • 每完成一个步骤,需要修订任务清单 - 标记状态或调整任务

    After completing each step, the task list needs to be revised—marking status or adjusting tasks.

现在让我们换个方式输入任务要求:请帮我详细分析贵州茅台这只股票,包括基本面、技术面和消息面。请先制定一个分析计划。

Now, let's change the way we input the task requirement: Please help me analyze the stock Kweichow Moutai in detail, including fundamentals, technical aspects, and news. Please first create an analysis plan.

再次通过LangSmith Studio观察执行过程,你会发现,这一次的工作循环有所不同!第一次的工具调用是write_todos,它会将LLM推理出的“代办事项”写入到State中。而后续每完成一个步骤,该工具会再次被调用 - 标记状态(或修订计划)。

Observing the execution process again through LangSmith Studio, you will find that this time the work cycle is different! The first tool call is write_todos, which writes the "to-do items" inferred by the LLM into the State. Subsequently, after completing each step, this tool is called again to mark the status (or revise the plan).

注意:如果你的任务过于简单,默认不会触发规划机制,以避免增加不必要的token和时间开销。

Note: If your task is too simple, the planning mechanism will not be triggered by default to avoid adding unnecessary token and time overhead.

文件系统:File System

想象下,当领导交给你复杂任务时,你是不是需要一个笔记本来记录重要事项或工作成果,必要时可以翻阅?DeepAgents的另一个重要特性 - “文件系统”,就类似这样的笔记本:给Agent配备一套虚拟文件系统与读写工具,可随时记录、查询与持久化任务过程中的信息。

Imagine when a leader assigns you a complex task, don't you need a notebook to record important matters or work results, which you can refer to when necessary? Another important feature of DeepAgents—the "file system"—is like such a notebook: Equip the Agent with a set of virtual file systems and read/write tools to record, query, and persist information during the task process at any time.

虚拟文件系统由可插拔、可扩展的后端(Backend)来实现,架构如下:

The virtual file system is implemented by pluggable, extensible backends (Backend), with the architecture as follows:

  • StateBackend:Agent的State作为存储,仅在本次线程有效。可用来在一次对话中卸载临时的中间结果,优化上下文空间。

    StateBackend: Uses the Agent's State as storage, valid only for the current thread. Can be used to offload temporary intermediate results in a single conversation, optimizing context space.

  • FileSystemBackend:本地文件系统目录作为存储,可长期保存。比如保存AI生成的创作文档或代码文件。

    FileSystemBackend: Uses the local file system directory as storage for long-term preservation. For example, saving AI-generated creative documents or code files.

  • StoreBackend:Store是LangGraph实现跨线程持久记忆的机制(可以是Redis、Postgres等实现)。你可以配置Store作为虚拟文件系统。

    StoreBackend: Store is LangGraph's mechanism for achieving cross-thread persistent memory (can be implemented with Redis, Postgres, etc.). You can configure Store as a virtual file system.

  • CompositeBackend:复合后端。比如默认使用StateBackend;但存储到/memories/的数据则使用StoreBackend以实现跨线程持久。

    CompositeBackend: A composite backend. For example, use StateBackend by default; but data stored to /memories/ uses StoreBackend to achieve cross-thread persistence.

此外,你可以编写自己的Backend,比如把虚拟文件系统映射到阿里云OSS;也可以扩展上述Backend,比如给FileSystemBackend增加安全检查。

Furthermore, you can write your own Backend, such as mapping the virtual file system to Alibaba Cloud OSS; you can also extend the above backends, such as adding security checks to FileSystemBackend.

现在我们继续用前面的Agent来体验该特性。

Now, let's continue using the previous Agent to experience this feature.

State作为Backend(默认)

State as Backend (Default)

首先不做任何代码修改,只对任务稍作修改:请分析贵州茅台,并将分析结果保存到 /reports/maotai_analysis.md 文件中。

First, without any code modifications, slightly change the task: Please analyze Kweichow Moutai and save the analysis results to the /reports/maotai_analysis.md file.

观察执行过程,你将会看到write_file工具的调用。由于没做任何指定,Agent会使用默认的StateBackend:将“文件”直接保存在State的Files字段。很显然,它并不是真实的文件,仅限本次线程有效。

Observing the execution process, you will see the write_file tool being called. Since no specification was made, the Agent uses the default StateBackend: "files" are directly saved in the State's Files field. Clearly, it is not a real file and is only valid for the current thread.

本地文件系统作为Backend

Local File System as Backend

现在给Agent更换另一个Backend的实现:

Now, change the Agent to use another Backend implementation:

from deepagents.backends import FilesystemBackend
agent = create_deep_agent(
    ...,
    backend=FilesystemBackend(root_dir="./fs", virtual_mode=True)
)

相同的输入任务下,你将不会在State看到Files字段,而是生成了真实的文件。

Under the same input task, you will not see the Files field in the State; instead, real files are generated.

LangGraph Store作为Backend

LangGraph Store as Backend

这是非常重要的一项能力。它可以让Deep Agents能够像访问文件系统一样,直接操作底层LangGraph的持久装置(Store),从而获得跨线程、跨会话、带向量检索能力的持续记忆能力。

This is a very important capability. It allows Deep Agents to directly operate the underlying LangGraph persistence device (Store) as if accessing a file system, thereby gaining continuous memory capabilities across threads and sessions, with vector retrieval.

关于LangGraph Store的应用,可参考LangGraph官方文档详细了解。

For details on the application of LangGraph Store, refer to the official LangGraph documentation.

继续修改我们的Agent,并同时演示CompositeBackend的能力:

Continue modifying our Agent while demonstrating the capabilities of CompositeBackend:

def create_backend(runtime):
    return CompositeBackend(
        default=FilesystemBackend(root_dir="./fs", virtual_mode=True),
        routes={
            "/memories/": StoreBackend(runtime)
        }
    )
agent = create_deep_agent(
    model=f"openai:{OPENAI_MODEL}",
    tools=main_tools,
    backend=create_backend,
    system_prompt=SYSTEM_PROMPT,
    debug=True
).with_config({"recursion_limit": RECURSION_LIMIT})

这里创建了一个复合的Backend:默认使用本地文件系统做后端;但如果路由路径是/memories/,则使用LangGraph Store作为后端(默认类型InMemoryStore)。

This creates a composite Backend: uses the local file system as the backend by default; but if the route path is /memories/, it uses LangGraph Store as the backend (default type InMemoryStore).

接着在系统提示中增加一些指令:

Then, add some instructions to the system prompt:

- 把股票分析结果保存成`/reports`下面的Markdown文件
- 把用户分析过的股票名称保存到`/memories/my_stocks.md`中,方便下次调用

现在启动一个运行线程,并输入任务。根据以上的设置:股票分析结果会被保存到本地文件系统;但分析过的股票名称将会被路由到LangGraph的持久记忆Store。所以你会在本地看到分析结果,但无法看到这里的my_stocks.md“文件”。

Now start a running thread and input the task. According to the above settings: stock analysis results will be saved to the local file system; but the names of analyzed stocks will be routed to LangGraph's persistent memory Store. Therefore, you will see the analysis results locally but cannot see the my_stocks.md "file" here.

为了验证my_stocks中的“记忆”,我们开启一个新的线程任务:我之前分析过哪些股票?

To verify the "memory" in my_stocks, we start a new thread task: Which stocks have I analyzed before?

此时Agent会调用read_file工具来读取Store,并输出结果。实际应用中,该功能可以用来实现诸如用户偏好记忆、知识积累

常见问题(FAQ)

DeepAgents框架主要解决传统AI智能体的哪些痛点?

DeepAgents旨在解决传统智能体在复杂场景下的脆弱性问题,如任务步骤不合理、工具调用错误、上下文膨胀和遗忘目标,通过内置能力简化开发。

DeepAgentsLangChainLangGraph之间是什么关系?

DeepAgentsLangChain推出的第三个独立开源框架,在LangGraph运行时和LangChain高层接口之上封装,通过create_deep_agent方法提供预设中间件能力。

DeepAgents为开发者提供了哪些开箱即用的核心能力?

框架抽象了编程智能体和深度研究智能体的经验,提供任务规划工具、虚拟文件系统、子智能体协作和长期记忆等内置能力,帮助构建复杂多步骤智能体。

← 返回文章列表
分享到:微博

版权与免责声明:本文仅用于信息分享与交流,不构成任何形式的法律、投资、医疗或其他专业建议,也不构成对任何结果的承诺或保证。

文中提及的商标、品牌、Logo、产品名称及相关图片/素材,其权利归各自合法权利人所有。本站内容可能基于公开资料整理,亦可能使用 AI 辅助生成或润色;我们尽力确保准确与合规,但不保证完整性、时效性与适用性,请读者自行甄别并以官方信息为准。

若本文内容或素材涉嫌侵权、隐私不当或存在错误,请相关权利人/当事人联系本站,我们将及时核实并采取删除、修正或下架等处理措施。 也请勿在评论或联系信息中提交身份证号、手机号、住址等个人敏感信息。