这是开始构建由 LLMs 驱动的 agents 和 applications 的最简单方式,内置 task planning、用于 context management 的 file systems、subagent-spawning 和 long-term memory。 你可以将 deep agents 用于任何 task,包括复杂的 multi-step tasks。 Deep Agents 是一种 “agent harness”。它与其他 agent frameworks 使用相同的 core tool calling loop,但内置了让 agents 能可靠处理真实 tasks 的 capabilities:

Take actions in an environment

通过 tools 执行动作,read 和 write files,并 execute code

Connect to your data

在合适时机加载 memories、skills 和 domain knowledge

Manage growing context

在 long runs 中 summarize history,并 offload large results

Parallelize tasks

委派给在 isolated context windows 中运行的 general 或 specialized subagents

Stay in the loop

在关键 decision points 暂停以等待 human approval

Improve over time

根据真实 usage 更新 memory、skills 和 prompts
请参阅 Harness capabilities,了解每个 component 的完整拆解。 deepagents 是一个基于 LangChain agents core building blocks 构建的 standalone library。它使用 LangGraph runtime 提供 durable execution、streaming、human-in-the-loop 和其他 features。 LangChain 是为你的 agents 提供 core building blocks 的 framework。 若要进一步了解 LangChain、LangGraph 和 Deep Agents 之间的差异,请参阅 Frameworks, runtimes, and harnesses。若要与 Anthropic 的 harness 进行 side-by-side comparison,请参阅 Deep Agents vs. Claude Agent SDK

Create a deep agent

# pip install -qU deepagents langchain-google-genai
from deepagents import create_deep_agent

def get_weather(city: str) -> str:
    """Get weather for a given city."""
    return f"It's always sunny in {city}!"

agent = create_deep_agent(
    model="google_genai:gemini-3.5-flash",
    tools=[get_weather],
    system_prompt="You are a helpful assistant",
)

# Run the agent
agent.invoke(
    {"messages": [{"role": "user", "content": "what is the weather in sf"}]}
)
请参阅 QuickstartCustomization guide,开始构建你自己的 Deep Agents agents 和 applications。
使用 LangSmith trace requests、debug agent behavior 并 evaluate outputs。按照 observability quickstart 完成设置。准备进入 production 时,请参阅 Going to production 了解 LangSmith deployment options。

Core capabilities

使用 Deep Agents SDK 构建可跨 任何 model provider 处理复杂 multi-step tasks 的 agents。SDK 随附以下 built-in capabilities:

Planning and task decomposition

内置 write_todos tool 让 agents 可以把 complex tasks 拆成 discrete steps、track progress,并在出现新信息时 adapt plans。

Context management

内置 context compression 会将 large tool inputs 和 results offload 到 virtual filesystem,并 summarizes older messages,让 agents 在 extended sessions 中保持有效。

Pluggable filesystem backends

通过 pluggable backends swap virtual filesystem:in-memory state、local disk、LangGraph store、composite routing,或带 read/write permission rules 的 custom backend。

Shell execution

Shell-capable backends 会添加 execute tool,用于 tests、builds、git operations 和 system tasks。Local development 时在 host 上使用 LocalShellBackend;需要与 host system 隔离时使用 sandbox backend

Interpreters

添加 interpreter,在 in-memory runtime 中运行 JavaScript。Interpreters 让 agents 无需 full shell environment,也能 programmatically compose tools、orchestrate subagents,并 transform structured data。

Subagent spawning

内置 task tool 会为 subtasks spawn general-purpose 或 specialized subagents,以实现 context isolation。对于 long-running 或 parallel work,async subagents 会在 background 中运行,并支持 progress checks、follow-ups 和 cancellation。

Streaming

Event streaming 会将 agent runs 暴露为 messages、tool calls、values 和 output 的 typed projections。Deep Agents 添加了 stream.subagents,让每个 delegated task 都有自己的 handle,并拥有独立 message、tool-call 和 nested subagent streams。

Long-term memory

使用 LangGraph 的 Memory Store 在 threads 和 conversations 之间持久化 memory。

Filesystem permissions

声明 permission rules,控制 agents 可以 read 或 write 哪些 files 和 directories。Subagents 可以 inherit 或 override parent 的 rules。

Human-in-the-loop

使用 LangGraph 的 interrupt capabilities 为 sensitive tool operations 配置 human approval

Skills

使用 reusable skills 扩展 agents,提供 specialized workflows、domain knowledge 和 custom instructions。

Smart defaults

附带 opinionated system prompts,教 model 在行动前 plan、verify work,并 manage context。你可以按需 customize 或 replace defaults。
若要构建不包含这些 builtin capabilities 的 custom agents,请考虑使用 LangChain 的 create_agent,或构建 custom LangGraph workflow。

Get started

Quickstart

构建你的 first deep agent

Customization

了解 customization options

Models

配置 models 和 providers

Backends

选择并配置 pluggable filesystem backends

Sandboxes

在 isolated environments 中 execute code

Interpreters

在 QuickJS 中 compose tools 和 transform data

Permissions

使用 permission rules 控制 filesystem access

Human-in-the-loop

为 sensitive operations 配置 approval

Code

使用 Deep Agents Code

ACP

通过 ACP 在 code editors 中使用 deep agents

Reference

查看 deepagents API reference