DeepAgents简介
这是开始构建由大型语言模型(LLM)驱动的智能体和应用程序的最简单方法,它内置了任务规划功能、用于上下文管理的文件系统、子智能体生成功能以及长期记忆功能。您可以将深度智能体应用于任何任务,包括复杂的多步骤任务。

快速创建DeepAgents
import os
from typing import Literal
from tavily import TavilyClient
from deepagents import create_deep_agent
tavily_client = TavilyClient(api_key=os.environ["TAVILY_API_KEY"])
def internet_search(
query: str,
max_results: int = 5,
topic: Literal["general", "news", "finance"] = "general",
include_raw_content: bool = False,
):
"""Run a web search"""
return tavily_client.search(
query,
max_results=max_results,
include_raw_content=include_raw_content,
topic=topic,
)
research_instructions = "You are an expert researcher. Your job is to conduct thorough research and then write a polished report."
agent = create_deep_agent(
model="openai:gpt-5.4",
tools=[internet_search],
system_prompt=research_instructions,
)
result = agent.invoke({"messages": [{"role": "user", "content": "What is langgraph?"}]})
# Print the agent's response
print(result["messages"][–1].content)
核心功能
1.Context Engineering
2.Backends
DeepAgents通过ls、read_file、write_file、edit_file、glob和grep等工具向代理暴露一个文件系统接口。这些工具通过可插拔后端进行操作。read_file工具在所有后端上原生支持图像文件(.png、.jpg、.jpeg、.gif、.webp),并将其作为多模态内容块返回。
Backend存在8种虚拟文件系统类型:

默认使用的Backends是StateBackend,当没有采用LangSmith平台的时候,使用StateBackend虚拟文件系统的时候,创建的文件是存在于运行时的State中的,也就是session/thread_id范围内的生命周期,如果设置了checkpoint,在会话中创建的文件会根据checkpoint采用的策略进行相应的持久化。

FilesystemBackend 在一个可配置的根目录下读写实际文件。
工作原理:
1.在可配置的根目录下读写真实文件。
2.您可以选择将virtual_mode设置为True,以便在root_dir下对路径进行沙盒处理和标准化。
3.采用安全路径解析,尽可能防止不安全的符号链接遍历,可使用ripgrep实现快速grep。
最适合:
1.您机器上的本地项目
2. CI沙箱
3.挂载的持久卷
3.Subagents & Async Subagents
4.Human-in-the-loop
5.Permissions
6.Memory
7.Skills
8.Sandboxes
9.Event streaming
10.Grading Rubrics
待补充。。。。