DeepAgents框架解析:LangChain如何简化复杂AI智能体开发?
DeepAgents is LangChain's new open-source framework designed to simplify the development of complex, multi-step, long-running AI agents by providing built-in capabilities like task planning, virtual file systems, and subagent collaboration, enabling developers to build more robust and capable agents with less code.
原文翻译: DeepAgents是LangChain推出的全新开源框架,旨在简化复杂、多步骤、长时间运行的AI智能体开发,通过提供任务规划、虚拟文件系统和子智能体协作等内置能力,使开发者能够用更少的代码构建更强大、更可靠的智能体。
DeepAgentsLangChain 官方发布的智能体工具链,基于 LangChain 和 LangGraph 构建,核心功能包括内置规划工具、文件系统后端以及生成子智能体的能力,旨在通过多层级协作模式处理复杂的代理任务。 Hands-on Analysis: An In-Depth Look at LangChain's New Deep Agent Framework
引言:LangChain 生态的新成员
Introduction: A New Member of the LangChain Ecosystem
前段时间,LangChain 公司正式发布了 LangChain 1.0 版本及其配套的 LangGraphA framework within the LangChain ecosystem for building stateful, multi-actor applications with language models. 1.0,标志着其通用智能体(Agent)框架已趋于成熟。在此坚实基础上,LangChain 团队进一步推出了一个全新的开源项目——DeepAgentsLangChain 官方发布的智能体工具链,基于 LangChain 和 LangGraph 构建,核心功能包括内置规划工具、文件系统后端以及生成子智能体的能力,旨在通过多层级协作模式处理复杂的代理任务。。该项目旨在显著提升智能体在复杂场景下的处理能力,致力于用更精简的代码实现更“深度”(Deep)的任务。
Recently, LangChain officially released LangChain 1.0 along with its companion LangGraphA framework within the LangChain ecosystem for building stateful, multi-actor applications with language models. 1.0, signifying the maturation of its general-purpose Agent framework. Building upon this solid foundation, the LangChain team has further introduced a brand-new open-source project—DeepAgentsLangChain 官方发布的智能体工具链,基于 LangChain 和 LangGraph 构建,核心功能包括内置规划工具、文件系统后端以及生成子智能体的能力,旨在通过多层级协作模式处理复杂的代理任务。. This project aims to significantly enhance an Agent's capabilities in complex scenarios, striving to accomplish more "Deep" tasks with more concise code.
本文将为您带来 DeepAgentsLangChain 官方发布的智能体工具链,基于 LangChain 和 LangGraph 构建,核心功能包括内置规划工具、文件系统后端以及生成子智能体的能力,旨在通过多层级协作模式处理复杂的代理任务。 的深度解读与实战体验。主要内容结构如下:
This article will provide an in-depth interpretation and hands-on experience with DeepAgentsLangChain 官方发布的智能体工具链,基于 LangChain 和 LangGraph 构建,核心功能包括内置规划工具、文件系统后端以及生成子智能体的能力,旨在通过多层级协作模式处理复杂的代理任务。. The main content is structured as follows:
- DeepAgentsLangChain 官方发布的智能体工具链,基于 LangChain 和 LangGraph 构建,核心功能包括内置规划工具、文件系统后端以及生成子智能体的能力,旨在通过多层级协作模式处理复杂的代理任务。:框架定位与核心能力概览 (DeepAgentsLangChain 官方发布的智能体工具链,基于 LangChain 和 LangGraph 构建,核心功能包括内置规划工具、文件系统后端以及生成子智能体的能力,旨在通过多层级协作模式处理复杂的代理任务。: Framework Positioning and Core Capabilities Overview)
- 通过实例理解 DeepAgentsLangChain 官方发布的智能体工具链,基于 LangChain 和 LangGraph 构建,核心功能包括内置规划工具、文件系统后端以及生成子智能体的能力,旨在通过多层级协作模式处理复杂的代理任务。:三大核心机制详解 (Understanding DeepAgentsLangChain 官方发布的智能体工具链,基于 LangChain 和 LangGraph 构建,核心功能包括内置规划工具、文件系统后端以及生成子智能体的能力,旨在通过多层级协作模式处理复杂的代理任务。 Through Examples: A Detailed Look at Three Core Mechanisms)
- DeepAgentsLangChain 官方发布的智能体工具链,基于 LangChain 和 LangGraph 构建,核心功能包括内置规划工具、文件系统后端以及生成子智能体的能力,旨在通过多层级协作模式处理复杂的代理任务。 原理总结与未来展望 (DeepAgentsLangChain 官方发布的智能体工具链,基于 LangChain 和 LangGraph 构建,核心功能包括内置规划工具、文件系统后端以及生成子智能体的能力,旨在通过多层级协作模式处理复杂的代理任务。 Principles Summary and Future Outlook)
- DeepAgentsLangChain 官方发布的智能体工具链,基于 LangChain 和 LangGraph 构建,核心功能包括内置规划工具、文件系统后端以及生成子智能体的能力,旨在通过多层级协作模式处理复杂的代理任务。: Framework Positioning and Core Capabilities Overview
- Understanding DeepAgentsLangChain 官方发布的智能体工具链,基于 LangChain 和 LangGraph 构建,核心功能包括内置规划工具、文件系统后端以及生成子智能体的能力,旨在通过多层级协作模式处理复杂的代理任务。 Through Examples: A Detailed Look at Three Core Mechanisms
- DeepAgentsLangChain 官方发布的智能体工具链,基于 LangChain 和 LangGraph 构建,核心功能包括内置规划工具、文件系统后端以及生成子智能体的能力,旨在通过多层级协作模式处理复杂的代理任务。 Principles Summary and Future Outlook
【本文相关源代码链接见文末】
[Source code links for this article are provided at the end.]
DeepAgentsLangChain 官方发布的智能体工具链,基于 LangChain 和 LangGraph 构建,核心功能包括内置规划工具、文件系统后端以及生成子智能体的能力,旨在通过多层级协作模式处理复杂的代理任务。:框架定位与核心能力概览
DeepAgentsLangChain 官方发布的智能体工具链,基于 LangChain 和 LangGraph 构建,核心功能包括内置规划工具、文件系统后端以及生成子智能体的能力,旨在通过多层级协作模式处理复杂的代理任务。: Framework Positioning and Core Capabilities Overview
我们最熟悉的一种智能体形态,是让大语言模型(LLM)在推理循环中调用工具,并最终完成任务。然而,在复杂任务环境下,这类智能体往往会显得“脆弱”:可能出现任务步骤规划不合理、工具调用错误、上下文信息不断膨胀甚至遗忘核心目标等问题;同时,它们也缺乏主动规划步骤、管理中间变量以及优化上下文的能力。
The most familiar form of an Agent involves having a Large Language Model (LLM) call tools within a reasoning loop to ultimately complete a task. However, in complex task environments, such Agents often appear "fragile": they may suffer from不合理 task step planning, incorrect tool calls, ever-expanding context information, or even forgetting the core objective. Furthermore, they typically lack the ability to proactively plan steps, manage intermediate variables, and optimize context.
若您在 LangChain 生态中进行开发,可以通过 LangGraphA framework within the LangChain ecosystem for building stateful, multi-actor applications with language models. 从底层精细控制工作流,例如决定何时由 AI 自主决策、何时采用固化流程,或选择使用 ReAct 还是 Plan-then-Execute 等范式。但这通常伴随着较高的实现复杂度。
If you are developing within the LangChain ecosystem, you can use LangGraphA framework within the LangChain ecosystem for building stateful, multi-actor applications with language models. to finely control workflows from the ground up, for instance, deciding when AI makes autonomous decisions versus when to use fixed processes, or choosing between paradigms like ReAct or Plan-then-Execute. However, this often comes with relatively high implementation complexity.
DeepAgentsLangChain 官方发布的智能体工具链,基于 LangChain 和 LangGraph 构建,核心功能包括内置规划工具、文件系统后端以及生成子智能体的能力,旨在通过多层级协作模式处理复杂的代理任务。 正是为了应对上述痛点而诞生。 其核心目标可以用一句话概括:
DeepAgentsLangChain 官方发布的智能体工具链,基于 LangChain 和 LangGraph 构建,核心功能包括内置规划工具、文件系统后端以及生成子智能体的能力,旨在通过多层级协作模式处理复杂的代理任务。 was born precisely to address the aforementioned pain points. Its core objective can be summarized in one sentence:
让复杂、多步骤、长时间运行的智能体更容易开发与构建。
Making complex, multi-step, long-running Agents easier to develop and build.
DeepAgentsLangChain 官方发布的智能体工具链,基于 LangChain 和 LangGraph 构建,核心功能包括内置规划工具、文件系统后端以及生成子智能体的能力,旨在通过多层级协作模式处理复杂的代理任务。 是什么?
What is DeepAgentsLangChain 官方发布的智能体工具链,基于 LangChain 和 LangGraph 构建,核心功能包括内置规划工具、文件系统后端以及生成子智能体的能力,旨在通过多层级协作模式处理复杂的代理任务。?
DeepAgentsLangChain 官方发布的智能体工具链,基于 LangChain 和 LangGraph 构建,核心功能包括内置规划工具、文件系统后端以及生成子智能体的能力,旨在通过多层级协作模式处理复杂的代理任务。 是 LangChain 公司在 LangGraphA framework within the LangChain ecosystem for building stateful, multi-actor applications with language models. 与 LangChain 之后推出的第三个独立开源智能体框架,与前者形成了清晰的分工协作关系。
DeepAgentsLangChain 官方发布的智能体工具链,基于 LangChain 和 LangGraph 构建,核心功能包括内置规划工具、文件系统后端以及生成子智能体的能力,旨在通过多层级协作模式处理复杂的代理任务。 is the third independent open-source Agent framework launched by LangChain Inc., following LangGraphA framework within the LangChain ecosystem for building stateful, multi-actor applications with language models. and LangChain, establishing a clear division of labor with its predecessors.
在最新的 LangChain 1.0 版本中,这三者在智能体开发中的定位如下:
In the latest LangChain 1.0 version, the positioning of these three in Agent development is as follows:
- LangGraphA framework within the LangChain ecosystem for building stateful, multi-actor applications with language models.:提供持久化与可观测的运行时(Runtime),用于构建底层工作流与智能体。
- LangChain:基于 LangGraphA framework within the LangChain ecosystem for building stateful, multi-actor applications with language models. 进行高层封装,提供更简洁的智能体接口(如
create_agent)与可扩展的中间件机制。 - DeepAgentsLangChain 官方发布的智能体工具链,基于 LangChain 和 LangGraph 构建,核心功能包括内置规划工具、文件系统后端以及生成子智能体的能力,旨在通过多层级协作模式处理复杂的代理任务。:在 LangChain 的高层接口与 LangGraphA framework within the LangChain ecosystem for building stateful, multi-actor applications with language models. 的运行时之上,进一步封装形成的“深度智能体”框架。其核心方法
create_deep_agent,本质上是在create_agent之上预置了一系列增强能力的中间件。
- LangGraphA framework within the LangChain ecosystem for building stateful, multi-actor applications with language models.: Provides a persistent and observable Runtime for building underlying workflows and Agents.
- LangChain: Offers a higher-level abstraction based on LangGraphA framework within the LangChain ecosystem for building stateful, multi-actor applications with language models., providing a more concise Agent interface (e.g.,
create_agent) and an extensible middleware mechanism.- DeepAgentsLangChain 官方发布的智能体工具链,基于 LangChain 和 LangGraph 构建,核心功能包括内置规划工具、文件系统后端以及生成子智能体的能力,旨在通过多层级协作模式处理复杂的代理任务。: A "Deep Agent" framework formed by further encapsulation on top of LangChain's high-level interface and LangGraphA framework within the LangChain ecosystem for building stateful, multi-actor applications with language models.'s runtime. Its core method,
create_deep_agent, essentially pre-configures a series of capability-enhancing middleware on top ofcreate_agent.
DeepAgentsLangChain 官方发布的智能体工具链,基于 LangChain 和 LangGraph 构建,核心功能包括内置规划工具、文件系统后端以及生成子智能体的能力,旨在通过多层级协作模式处理复杂的代理任务。 提供了哪些增强能力?
What Enhanced Capabilities Does DeepAgentsLangChain 官方发布的智能体工具链,基于 LangChain 和 LangGraph 构建,核心功能包括内置规划工具、文件系统后端以及生成子智能体的能力,旨在通过多层级协作模式处理复杂的代理任务。 Provide?
目前在复杂任务智能体领域,最成功的实践主要有两类:编程智能体与深度研究智能体。DeepAgentsLangChain 官方发布的智能体工具链,基于 LangChain 和 LangGraph 构建,核心功能包括内置规划工具、文件系统后端以及生成子智能体的能力,旨在通过多层级协作模式处理复杂的代理任务。 的灵感正来源于此类应用——这些“深度智能体”通过引入任务规划工具、子智能体、文件系统、详细提示等手段,在实践中有效突破了传统智能体的局限。
Currently, the most successful practices in the field of complex task Agents fall into two main categories: programming agents and deep research agents. DeepAgentsLangChain 官方发布的智能体工具链,基于 LangChain 和 LangGraph 构建,核心功能包括内置规划工具、文件系统后端以及生成子智能体的能力,旨在通过多层级协作模式处理复杂的代理任务。 draws inspiration from such applications—these "deep agents" have effectively broken through the limitations of traditional Agents in practice by incorporating planning tools, sub-agents, file systems, detailed prompts, and other means.
DeepAgentsLangChain 官方发布的智能体工具链,基于 LangChain 和 LangGraph 构建,核心功能包括内置规划工具、文件系统后端以及生成子智能体的能力,旨在通过多层级协作模式处理复杂的代理任务。 将这些实践经验抽象为通用框架,开箱即用地提供了以下关键能力:
DeepAgentsLangChain 官方发布的智能体工具链,基于 LangChain 和 LangGraph 构建,核心功能包括内置规划工具、文件系统后端以及生成子智能体的能力,旨在通过多层级协作模式处理复杂的代理任务。 abstracts these practical experiences into a general framework, providing the following key capabilities out-of-the-box:
- 任务规划 (Task Planning)
- 虚拟文件系统 (Virtual File System)
- 长期记忆 (Long-term Memory)
- 分工协作(子智能体) (Division of Labor and Collaboration (Sub-agents))
- Task Planning
- Virtual File System
- Long-term Memory
- Division of Labor and Collaboration (Sub-agents)
下文我们将通过一个完整的实例来具体体验 DeepAgentsLangChain 官方发布的智能体工具链,基于 LangChain 和 LangGraph 构建,核心功能包括内置规划工具、文件系统后端以及生成子智能体的能力,旨在通过多层级协作模式处理复杂的代理任务。 的这些独特能力。
We will experience these unique capabilities of DeepAgentsLangChain 官方发布的智能体工具链,基于 LangChain 和 LangGraph 构建,核心功能包括内置规划工具、文件系统后端以及生成子智能体的能力,旨在通过多层级协作模式处理复杂的代理任务。 through a complete example later.
何时选择使用 DeepAgentsLangChain 官方发布的智能体工具链,基于 LangChain 和 LangGraph 构建,核心功能包括内置规划工具、文件系统后端以及生成子智能体的能力,旨在通过多层级协作模式处理复杂的代理任务。?
When to Choose DeepAgentsLangChain 官方发布的智能体工具链,基于 LangChain 和 LangGraph 构建,核心功能包括内置规划工具、文件系统后端以及生成子智能体的能力,旨在通过多层级协作模式处理复杂的代理任务。?
理解了 DeepAgentsLangChain 官方发布的智能体工具链,基于 LangChain 和 LangGraph 构建,核心功能包括内置规划工具、文件系统后端以及生成子智能体的能力,旨在通过多层级协作模式处理复杂的代理任务。、LangChain 和 LangGraphA framework within the LangChain ecosystem for building stateful, multi-actor applications with language models. 三者的分层定位后,这个问题可以简单地总结为:
Understanding the layered positioning of DeepAgentsLangChain 官方发布的智能体工具链,基于 LangChain 和 LangGraph 构建,核心功能包括内置规划工具、文件系统后端以及生成子智能体的能力,旨在通过多层级协作模式处理复杂的代理任务。, LangChain, and LangGraphA framework within the LangChain ecosystem for building stateful, multi-actor applications with language models., this question can be simply summarized as:
当您需要构建复杂的、多步骤的、长时间运行的智能体,并且希望它具备任务规划、文件系统、长期记忆等高级能力时,应考虑使用 DeepAgentsLangChain 官方发布的智能体工具链,基于 LangChain 和 LangGraph 构建,核心功能包括内置规划工具、文件系统后端以及生成子智能体的能力,旨在通过多层级协作模式处理复杂的代理任务。。
You should consider using DeepAgentsLangChain 官方发布的智能体工具链,基于 LangChain 和 LangGraph 构建,核心功能包括内置规划工具、文件系统后端以及生成子智能体的能力,旨在通过多层级协作模式处理复杂的代理任务。 when you need to build complex, multi-step, long-running Agents and desire advanced capabilities such as task planning, file systems, and long-term memory.
而对于一些步骤简单的任务,直接使用 LangChain 提供的 create_agent 接口通常就已足够。
For some simple, step-by-step tasks, using the
create_agentinterface provided by LangChain is usually sufficient.
通过 DeepAgentsLangChain 官方发布的智能体工具链,基于 LangChain 和 LangGraph 构建,核心功能包括内置规划工具、文件系统后端以及生成子智能体的能力,旨在通过多层级协作模式处理复杂的代理任务。,开发者无需从零开始设计长流程智能体的复杂逻辑,只需提供自定义工具和任务说明等核心要素,就能快速构建一个功能强大的“深度智能体”。
With DeepAgentsLangChain 官方发布的智能体工具链,基于 LangChain 和 LangGraph 构建,核心功能包括内置规划工具、文件系统后端以及生成子智能体的能力,旨在通过多层级协作模式处理复杂的代理任务。, developers do not need to design the complex logic of long-process Agents from scratch. By simply providing core elements such as custom tools and task descriptions, they can quickly build a powerful "deep agent."
通过实例理解 DeepAgentsLangChain 官方发布的智能体工具链,基于 LangChain 和 LangGraph 构建,核心功能包括内置规划工具、文件系统后端以及生成子智能体的能力,旨在通过多层级协作模式处理复杂的代理任务。:三大核心机制详解
Understanding DeepAgentsLangChain 官方发布的智能体工具链,基于 LangChain 和 LangGraph 构建,核心功能包括内置规划工具、文件系统后端以及生成子智能体的能力,旨在通过多层级协作模式处理复杂的代理任务。 Through Examples: A Detailed Look at Three Core Mechanisms
我们将从构建一个最简单的智能体开始,逐步细化和丰富其能力。在这个过程中,您可以清晰地看到 DeepAgentsLangChain 官方发布的智能体工具链,基于 LangChain 和 LangGraph 构建,核心功能包括内置规划工具、文件系统后端以及生成子智能体的能力,旨在通过多层级协作模式处理复杂的代理任务。 是如何在 LangGraphA framework within the LangChain ecosystem for building stateful, multi-actor applications with language models. 与 LangChain 的基础上“添砖加瓦”,以适应更复杂的任务环境。
We will start by building the simplest Agent and gradually refine and enrich its capabilities. Throughout this process, you can clearly see how DeepAgentsLangChain 官方发布的智能体工具链,基于 LangChain 和 LangGraph 构建,核心功能包括内置规划工具、文件系统后端以及生成子智能体的能力,旨在通过多层级协作模式处理复杂的代理任务。 "adds bricks and tiles" on top of LangGraphA framework within the LangChain ecosystem for building stateful, multi-actor applications with language models. and LangChain to adapt to more complex task environments.
首先,我们设计一个简单的应用场景:
First, let's design a simple application scenario:
构建一个借助搜索与金融数据接口等工具进行股票分析的智能体。
Build an Agent that performs stock analysis using tools such as search and financial data APIs.
初始版本构建
Initial Version Construction
最初,这个智能体看起来像一个标准的 ReAct 范式智能体。唯一的区别在于使用了 DeepAgentsLangChain 官方发布的智能体工具链,基于 LangChain 和 LangGraph 构建,核心功能包括内置规划工具、文件系统后端以及生成子智能体的能力,旨在通过多层级协作模式处理复杂的代理任务。 的 create_deep_agent 方法,而非 LangChain 的 create_agent(其前身是 LangGraphA framework within the LangChain ecosystem for building stateful, multi-actor applications with language models. 中的 create_react_agent)。
Initially, this Agent appears to be a standard ReAct paradigm Agent. The only difference lies in using DeepAgentsLangChain 官方发布的智能体工具链,基于 LangChain 和 LangGraph 构建,核心功能包括内置规划工具、文件系统后端以及生成子智能体的能力,旨在通过多层级协作模式处理复杂的代理任务。'
create_deep_agentmethod instead of LangChain'screate_agent(whose predecessor wascreate_react_agentin LangGraphA framework within the LangChain ecosystem for building stateful, multi-actor applications with language models.).
# === 系统指令 ===
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})
# === System Instructions ===SYSTEM_PROMPT = """You are a stock analysis assistant. Your task is to help users analyze stocks, using the search tool to find relevant information.* Workflow: ...* Output Requirements: ..."""main_tools = [search, # General web search tool]# === Create 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})
为了更好观测智能体的运行,我们通过 LangGraphA framework within the LangChain ecosystem for building stateful, multi-actor applications with language models. 命令行工具来部署和启动它:
To better observe the Agent's operation, we deploy and start it using the LangGraphA framework within the LangChain ecosystem for building stateful, multi-actor applications with language models. command-line tool:
> langgraph dev
然后在出现的 LangSmith Studio 界面上输入消息:“请帮我分析贵州茅台这只股票。”
Then, enter the message on the appeared LangSmith Studio interface: "Please help me analyze the stock Kweichow Moutai."
您会发现它的运行过程与普通的智能体几乎没有区别。这是正常的,因为在没有触发其“深度能力”的情况下,DeepAgentsLangChain 官方发布的智能体工具链,基于 LangChain 和 LangGraph 构建,核心功能包括内置规划工具、文件系统后端以及生成子智能体的能力,旨在通过多层级协作模式处理复杂的代理任务。 与普通智能体的执行路径是相同的。
You will find that its operation process is almost indistinguishable from a regular Agent. This is normal because, without triggering its "deep capabilities," the execution path of DeepAgentsLangChain 官方发布的智能体工具链,基于 LangChain 和 LangGraph 构建,核心功能包括内置规划工具、文件系统后端以及生成子智能体的能力,旨在通过多层级协作模式处理复杂的代理任务。 is the same as that of a regular Agent.
现在,让我们来触发 DeepAgentsLangChain 官方发布的智能体工具链,基于 LangChain 和 LangGraph 构建,核心功能包括内置规划工具、文件系统后端以及生成子智能体的能力,旨在通过多层级协作模式处理复杂的代理任务。 的第一个核心特性:任务规划。
Now, let's trigger the first core feature of DeepAgentsLangChain 官方发布的智能体工具链,基于 LangChain 和 LangGraph 构建,核心功能包括内置规划工具、文件系统后端以及生成子智能体的能力,旨在通过多层级协作模式处理复杂的代理任务。: Task Planning.
核心机制一:任务规划
Core Mechanism One: Task Planning
单纯依赖大语言模型来完成复杂任务的长期规划与执行,很容易发生目标偏离。各大模型厂商推出的“深度智能体”(如 OpenAI Deep Research、Claude Code)背后,除了训练特殊的智能体推理模型外,都采用了类似的策略:
Relying solely on Large Language Models for long-term planning and execution of complex tasks can easily lead to goal deviation. Behind the "deep agents" launched by major model providers (e.g., OpenAI Deep Research, Claude Code), apart from training specialized agent reasoning models, a similar strategy is employed:
在执行前先列出步骤、制定计划,然后逐一跟踪执行,并在必要时进行调整。
List steps and make a plan before execution, then track and execute them one by one, making adjustments when necessary.
DeepAgentsLangChain 官方发布的智能体工具链,基于 LangChain 和 LangGraph 构建,核心功能包括内置规划工具、文件系统后端以及生成子智能体的能力,旨在通过多层级协作模式处理复杂的代理任务。 中的任务规划能力是通过一个内置工具 write_todos 来实现的。它会在以下条件下触发:
The task planning capability in DeepAgentsLangChain 官方发布的智能体工具链,基于 LangChain 和 LangGraph 构建,核心功能包括内置规划工具、文件系统后端以及生成子智能体的能力,旨在通过多层级协作模式处理复杂的代理任务。 is implemented through a built-in tool called
write_todos. It triggers under the following conditions:
- 任务目标比较复杂,特别是涉及较多的步骤时。
- 用户明确提示要求 LLM 先进行规划再执行。
- 每完成一个步骤,需要修订任务清单——标记状态或调整后续任务。
- When the task objective is relatively complex, especially involving multiple steps.
- When the user explicitly instructs the LLM to plan first before executing.
- When each completed step requires revising the task list—marking status or adjusting subsequent tasks.
现在,让我们换一种方式输入任务要求,例如:“请为我制定一个详细的贵州茅台股票分析计划,并分步执行。”
Now, let's input the task requirement differently, for example: "Please create a detailed analysis plan for Kweichow Moutai stock and execute it step by step."
再次通过 LangSmith Studio 观察执行过程,您会发现工作循环有所不同!第一次的工具调用变成了 write_todos,它会将 LLM 推理出的“待办事项”写入到状态(State)中。
Observing the execution process again through LangSmith Studio, you will find the work loop is different! The first tool call becomes
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 task 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 consumption and time overhead.
核心机制二:虚拟文件系统
Core Mechanism Two: Virtual File System
想象一下,当领导交给您一项复杂任务时,您是不是需要一个笔记本来记录重要事项或工作成果,以便必要时随时翻阅?
Imagine when a manager assigns you a complex task, don't you need a notebook to record important matters or work results for easy reference when necessary?
DeepAgentsLangChain 官方发布的智能体工具链,基于 LangChain 和 LangGraph 构建,核心功能包括内置规划工具、文件系统后端以及生成子智能体的能力,旨在通过多层级协作模式处理复杂的代理任务。 的另一个重要特性——“虚拟文件系统”,就类似于这样的笔记本:
Another important feature of DeepAgentsLangChain 官方发布的智能体工具链,基于 LangChain 和 LangGraph 构建,核心功能包括内置规划工具、文件系统后端以及生成子智能体的能力,旨在通过多层级协作模式处理复杂的代理任务。—the "Virtual File System"—is akin to such a notebook:
为智能体配备一套虚拟文件系统与读写工具,使其能够随时记录、查询与持久化任务过程中的信息。
Equip the Agent with a set of virtual file systems and read/write tools, enabling it to record, query, and persist information during the task process at any time.
例如,作为一个客服智能体,可以将与客户每次交互的摘要存放在这个虚拟文件系统(如路径:/memories/{user_id}/ 下),当客户下次来访时即可调取历史记录。
For example, as a customer service Agent, it can store summaries of each interaction with a customer in this virtual file system (e.g., under the path:
/memories/{user_id}/), allowing retrieval of historical records when the customer visits next time.
虚拟文件系统由可插拔、可扩展的后端(Backend)来实现,其架构如下:
The virtual file system is implemented by pluggable, extensible backends (Backend), with an architecture as follows:
- StateBackend:以智能体的状态(State)作为存储,仅在本次运行线程内有效。可用于在一次对话中卸载临时的中间结果,以优化上下文空间。
- FileSystemBackend:以本地文件系统目录作为存储,可实现长期保存。例如,保存 AI 生成的创作文档或代码文件。
- StoreBackend:Store 是 LangGraphA framework within the LangChain ecosystem for building stateful, multi-actor applications with language models. 实现跨线程持久化记忆的机制(可以通过 Redis、PostgreSQL 等实现)。您可以配置 Store 作为虚拟文件系统的后端。
- CompositeBackend:复合后端。例如,默认使用 StateBackend,但存储到
"/memories/"路径的数据则使用 StoreBackend,以实现跨线程持久化。
- StateBackend: Uses the Agent's State as storage, valid only within the current runtime thread. Can be used to offload temporary intermediate results within a single conversation to optimize context space.
- FileSystemBackend: Uses the local filesystem directory as storage, enabling long-term persistence. For example, saving AI-generated creative documents or code files.
- StoreBackend: Store is LangGraphA framework within the LangChain ecosystem for building stateful, multi-actor applications with language models.'s mechanism for implementing cross-thread persistent memory (can be implemented via Redis, PostgreSQL, etc.). You can configure a Store as the backend for the virtual file system.
- CompositeBackend: A composite backend. For example, using StateBackend by default, but data stored under the
"/memories/"path uses StoreBackend to achieve cross-thread persistence.
此外,您可以编写自己的 Backend,例如将虚拟文件系统映射到阿里云 OSS;也可以扩展上述 Backend,例如为 FileSystemBackend 增加安全检查逻辑。
Furthermore, you can write your own Backend, for instance, mapping the virtual file system to Alibaba Cloud OSS; you can also extend the aforementioned Backends, such as adding security checks to FileSystemBackend.
现在,我们继续用前面的智能体来体验文件系统特性。
Now, let's continue using the previous Agent to experience the file system feature.
1. 使用 State 作为后端(默认)
- Using State as Backend (Default)
首先,不做任何代码修改,只对任务描述稍作调整,例如加入“请将分析过程中的关键数据记录下来”的
常见问题(FAQ)
DeepAgentsLangChain 官方发布的智能体工具链,基于 LangChain 和 LangGraph 构建,核心功能包括内置规划工具、文件系统后端以及生成子智能体的能力,旨在通过多层级协作模式处理复杂的代理任务。框架主要解决什么开发痛点?
DeepAgentsLangChain 官方发布的智能体工具链,基于 LangChain 和 LangGraph 构建,核心功能包括内置规划工具、文件系统后端以及生成子智能体的能力,旨在通过多层级协作模式处理复杂的代理任务。旨在解决复杂、多步骤、长时间运行的AI智能体开发难题,如任务规划不合理、工具调用错误、上下文膨胀等问题,让开发者能用更少代码构建更强大的智能体。
DeepAgentsLangChain 官方发布的智能体工具链,基于 LangChain 和 LangGraph 构建,核心功能包括内置规划工具、文件系统后端以及生成子智能体的能力,旨在通过多层级协作模式处理复杂的代理任务。与LangChain、LangGraphA framework within the LangChain ecosystem for building stateful, multi-actor applications with language models.是什么关系?
DeepAgentsLangChain 官方发布的智能体工具链,基于 LangChain 和 LangGraph 构建,核心功能包括内置规划工具、文件系统后端以及生成子智能体的能力,旨在通过多层级协作模式处理复杂的代理任务。是LangChain生态中第三个独立开源框架,在LangGraphA framework within the LangChain ecosystem for building stateful, multi-actor applications with language models.运行时和LangChain高层接口之上进行封装,通过create_deep_agent方法预置增强能力,形成分工协作的深度智能体框架。
DeepAgentsLangChain 官方发布的智能体工具链,基于 LangChain 和 LangGraph 构建,核心功能包括内置规划工具、文件系统后端以及生成子智能体的能力,旨在通过多层级协作模式处理复杂的代理任务。的核心优势体现在哪些方面?
框架提供任务规划、虚拟文件系统、子智能体协作等内置能力,显著提升智能体在复杂场景的处理能力,通过预置中间件降低实现复杂度,实现更精简的深度任务开发。
版权与免责声明:本文仅用于信息分享与交流,不构成任何形式的法律、投资、医疗或其他专业建议,也不构成对任何结果的承诺或保证。
文中提及的商标、品牌、Logo、产品名称及相关图片/素材,其权利归各自合法权利人所有。本站内容可能基于公开资料整理,亦可能使用 AI 辅助生成或润色;我们尽力确保准确与合规,但不保证完整性、时效性与适用性,请读者自行甄别并以官方信息为准。
若本文内容或素材涉嫌侵权、隐私不当或存在错误,请相关权利人/当事人联系本站,我们将及时核实并采取删除、修正或下架等处理措施。 也请勿在评论或联系信息中提交身份证号、手机号、住址等个人敏感信息。