deep-agents-core by langchain-ai/langchain-skills
npx skills add https://github.com/langchain-ai/langchain-skills --skill deep-agents-coreformat with YAML frontmatter for skill discovery; skills load on-demand based on agent relevance rather than at startup
SKILL.md
代理框架自动提供这些能力 - 您只需配置,无需实现。
| 何时使用深度代理 | 何时使用 LangChain 的 create_agent |
|---|---|
| 需要规划的多步骤任务 | 简单的、单一目的的任务 |
| 需要文件管理的大上下文 | 上下文适合单个提示 |
| 需要专用子代理 | 单个代理足够 |
| 跨会话的持久记忆 | 临时的、单会话工作 |
| 如果您需要... | 中间件 |
| --- | --- |
| 跟踪复杂任务 | TodoListMiddleware |
广告位招租
在这里展示您的产品或服务
触达数万 AI 开发者,精准高效
| 管理文件上下文 | FilesystemMiddleware |
| 委托工作 | SubAgentMiddleware |
| 添加人工审批 | HumanInTheLoopMiddleware |
| 加载技能 | SkillsMiddleware |
| 访问记忆 | MemoryMiddleware |
@tool def get_weather(city: str) -> str: """Get the weather for a given city.""" return f"It is always sunny in {city}"
agent = create_deep_agent( model="claude-sonnet-4-5-20250929", tools=[get_weather], system_prompt="You are a helpful assistant" )
config = {"configurable": {"thread_id": "user-123"}} result = agent.invoke({ "messages": [{"role": "user", "content": "What's the weather in Tokyo?"}] }, config=config)
</python>
<typescript>
创建一个带有自定义工具的基础深度代理,并使用用户消息调用它。
```typescript
import { createDeepAgent } from "deepagents";
import { tool } from "@langchain/core/tools";
import { z } from "zod";
const getWeather = tool(
async ({ city }) => `It is always sunny in ${city}`,
{ name: "get_weather", description: "Get weather for a city", schema: z.object({ city: z.string() }) }
);
const agent = await createDeepAgent({
model: "claude-sonnet-4-5-20250929",
tools: [getWeather],
systemPrompt: "You are a helpful assistant"
});
const config = { configurable: { thread_id: "user-123" } };
const result = await agent.invoke({
messages: [{ role: "user", content: "What's the weather in Tokyo?" }]
}, config);
agent = create_deep_agent( name="my-assistant", model="claude-sonnet-4-5-20250929", tools=[custom_tool1, custom_tool2], system_prompt="Custom instructions", subagents=[research_agent, code_agent], backend=FilesystemBackend(root_dir=".", virtual_mode=True), interrupt_on={"write_file": True}, skills=["./skills/"], checkpointer=MemorySaver(), store=InMemoryStore() )
</python>
<typescript>
使用所有可用选项配置深度代理,包括子代理、技能和持久化。
```typescript
import { createDeepAgent, FilesystemBackend } from "deepagents";
import { MemorySaver, InMemoryStore } from "@langchain/langgraph";
const agent = await createDeepAgent({
name: "my-assistant",
model: "claude-sonnet-4-5-20250929",
tools: [customTool1, customTool2],
systemPrompt: "Custom instructions",
subagents: [researchAgent, codeAgent],
backend: new FilesystemBackend({ rootDir: ".", virtualMode: true }),
interruptOn: { write_file: true },
skills: ["./skills/"],
checkpointer: new MemorySaver(),
store: new InMemoryStore()
});
write_todos - 跟踪多步骤任务ls, read_file, write_file, edit_file, glob, greptask - 生成专用子代理skills/
└── my-skill/
├── SKILL.md # 必需:主技能文件
├── examples.py # 可选:支持文件
└── templates/ # 可选:模板
---
name: my-skill
description: Clear, specific description of what this skill does
---
# Skill Name
## 概述
关于技能用途的简要说明。
## 使用时机
此技能适用的条件。
## 使用说明
面向代理的分步指导。
| 技能 | 记忆 (AGENTS.md) |
|---|---|
| 按需加载 | 启动时始终加载 |
| 任务特定指令 | 通用偏好 |
| 大型文档 | 紧凑的上下文 |
| 目录中的 SKILL.md 文件 | 单个 AGENTS.md 文件 |
agent = create_deep_agent( backend=FilesystemBackend(root_dir=".", virtual_mode=True), skills=["./skills/"], checkpointer=MemorySaver() )
result = agent.invoke({ "messages": [{"role": "user", "content": "Use the python-testing skill"}] }, config={"configurable": {"thread_id": "session-1"}})
</python>
<typescript>
为按需技能加载设置带有技能目录和文件系统后端的代理。
```typescript
import { createDeepAgent, FilesystemBackend } from "deepagents";
import { MemorySaver } from "@langchain/langgraph";
const agent = await createDeepAgent({
backend: new FilesystemBackend({ rootDir: ".", virtualMode: true }),
skills: ["./skills/"],
checkpointer: new MemorySaver()
});
const result = await agent.invoke({
messages: [{ role: "user", content: "Use the python-testing skill" }]
}, { configurable: { thread_id: "session-1" } });
store = InMemoryStore()
..."""
store.put( namespace=("filesystem",), key="/skills/python-testing/SKILL.md", value=create_file_data(skill_content) )
agent = create_deep_agent( backend=lambda rt: StoreBackend(rt), store=store, skills=["/skills/"] )
</python>
</ex-skills-with-store-backend>
<boundaries>
### 代理可以配置的内容
- 模型选择和参数
- 额外的自定义工具
- 系统提示词定制
- 后端存储策略
- 哪些工具需要审批
- 带有专用工具的自定义子代理
### 代理无法配置的内容
- 核心中间件移除(TodoList、Filesystem、SubAgent 始终存在)
- write_todos、task 或 filesystem 工具的名称
- SKILL.md 的前置元数据格式
</boundaries>
<fix-checkpointer-for-interrupts>
<python>
中断需要检查点。
```python
# 错误
agent = create_deep_agent(interrupt_on={"write_file": True})
# 正确
agent = create_deep_agent(interrupt_on={"write_file": True}, checkpointer=MemorySaver())
// 正确 const agent = await createDeepAgent({ interruptOn: { write_file: true }, checkpointer: new MemorySaver() });
</typescript>
</fix-checkpointer-for-interrupts>
<fix-store-for-memory>
<python>
StoreBackend 需要 Store 实例来实现跨线程的持久记忆。
```python
# 错误
agent = create_deep_agent(backend=lambda rt: StoreBackend(rt))
# 正确
agent = create_deep_agent(backend=lambda rt: StoreBackend(rt), store=InMemoryStore())
// 正确 const agent = await createDeepAgent({ backend: (config) => new StoreBackend(config), store: new InMemoryStore() });
</typescript>
</fix-store-for-memory>
<fix-thread-id-for-conversations>
<python>
使用一致的 thread_id 以在多次调用间维护对话上下文。
```python
# 错误:每次调用都是隔离的
agent.invoke({"messages": [{"role": "user", "content": "Hi"}]})
agent.invoke({"messages": [{"role": "user", "content": "What did I say?"}]})
# 正确
config = {"configurable": {"thread_id": "user-123"}}
agent.invoke({"messages": [...]}, config=config)
agent.invoke({"messages": [...]}, config=config)
// 正确 const config = { configurable: { thread_id: "user-123" } }; await agent.invoke({ messages: [...] }, config); await agent.invoke({ messages: [...] }, config);
</typescript>
</fix-thread-id-for-conversations>
<fix-frontmatter-required>
```markdown
# 错误:SKILL.md 中缺少前置元数据
# My Skill
This is my skill...
# 正确:包含 YAML 前置元数据
---
name: my-skill
description: Python testing best practices with pytest fixtures and mocking
---
# My Skill
This is my skill...
agent = create_deep_agent( backend=FilesystemBackend(root_dir=".", virtual_mode=True), skills=["./skills/"] )
</python>
</fix-backend-for-skills>
<fix-specific-skill-descriptions>
使用具体的描述来帮助代理决定何时使用技能。
```markdown
# 错误:模糊的描述
---
name: helper
description: Helpful skill
---
# 正确:具体的描述
---
name: python-testing
description: Python testing best practices with pytest fixtures, mocking, and async patterns
---
agent = create_deep_agent( skills=["/main-skills/"], subagents=[{"name": "helper", "skills": ["/helper-skills/"], ...}] )
</python>
</fix-subagent-skills>
每周安装量
2.3K
代码仓库
GitHub 星标数
423
首次出现
2026年3月3日
安全审计
安装于
claude-code1.9K
codex1.8K
cursor1.8K
github-copilot1.8K
opencode1.8K
gemini-cli1.8K
format with YAML frontmatter for skill discovery; skills load on-demand based on agent relevance rather than at startup
SKILL.md
The agent harness provides these capabilities automatically - you configure, not implement.
| Use Deep Agents When | Use LangChain's create_agent When |
|---|---|
| Multi-step tasks requiring planning | Simple, single-purpose tasks |
| Large context requiring file management | Context fits in a single prompt |
| Need for specialized subagents | Single agent is sufficient |
| Persistent memory across sessions | Ephemeral, single-session work |
| If you need to... | Middleware |
| --- | --- |
| Track complex tasks | TodoListMiddleware |
| Manage file context | FilesystemMiddleware |
| Delegate work | SubAgentMiddleware |
| Add human approval | HumanInTheLoopMiddleware |
| Load skills | SkillsMiddleware |
| Access memory | MemoryMiddleware |
@tool def get_weather(city: str) -> str: """Get the weather for a given city.""" return f"It is always sunny in {city}"
agent = create_deep_agent( model="claude-sonnet-4-5-20250929", tools=[get_weather], system_prompt="You are a helpful assistant" )
config = {"configurable": {"thread_id": "user-123"}} result = agent.invoke({ "messages": [{"role": "user", "content": "What's the weather in Tokyo?"}] }, config=config)
</python>
<typescript>
Create a basic deep agent with a custom tool and invoke it with a user message.
```typescript
import { createDeepAgent } from "deepagents";
import { tool } from "@langchain/core/tools";
import { z } from "zod";
const getWeather = tool(
async ({ city }) => `It is always sunny in ${city}`,
{ name: "get_weather", description: "Get weather for a city", schema: z.object({ city: z.string() }) }
);
const agent = await createDeepAgent({
model: "claude-sonnet-4-5-20250929",
tools: [getWeather],
systemPrompt: "You are a helpful assistant"
});
const config = { configurable: { thread_id: "user-123" } };
const result = await agent.invoke({
messages: [{ role: "user", content: "What's the weather in Tokyo?" }]
}, config);
agent = create_deep_agent( name="my-assistant", model="claude-sonnet-4-5-20250929", tools=[custom_tool1, custom_tool2], system_prompt="Custom instructions", subagents=[research_agent, code_agent], backend=FilesystemBackend(root_dir=".", virtual_mode=True), interrupt_on={"write_file": True}, skills=["./skills/"], checkpointer=MemorySaver(), store=InMemoryStore() )
</python>
<typescript>
Configure a deep agent with all available options including subagents, skills, and persistence.
```typescript
import { createDeepAgent, FilesystemBackend } from "deepagents";
import { MemorySaver, InMemoryStore } from "@langchain/langgraph";
const agent = await createDeepAgent({
name: "my-assistant",
model: "claude-sonnet-4-5-20250929",
tools: [customTool1, customTool2],
systemPrompt: "Custom instructions",
subagents: [researchAgent, codeAgent],
backend: new FilesystemBackend({ rootDir: ".", virtualMode: true }),
interruptOn: { write_file: true },
skills: ["./skills/"],
checkpointer: new MemorySaver(),
store: new InMemoryStore()
});
write_todos - Track multi-step tasksls, read_file, write_file, edit_file, glob, greptask - Spawn specialized subagentsskills/
└── my-skill/
├── SKILL.md # Required: main skill file
├── examples.py # Optional: supporting files
└── templates/ # Optional: templates
---
name: my-skill
description: Clear, specific description of what this skill does
---
# Skill Name
## Overview
Brief explanation of the skill's purpose.
## When to Use
Conditions when this skill applies.
## Instructions
Step-by-step guidance for the agent.
| Skills | Memory (AGENTS.md) |
|---|---|
| On-demand loading | Always loaded at startup |
| Task-specific instructions | General preferences |
| Large documentation | Compact context |
| SKILL.md in directories | Single AGENTS.md file |
agent = create_deep_agent( backend=FilesystemBackend(root_dir=".", virtual_mode=True), skills=["./skills/"], checkpointer=MemorySaver() )
result = agent.invoke({ "messages": [{"role": "user", "content": "Use the python-testing skill"}] }, config={"configurable": {"thread_id": "session-1"}})
</python>
<typescript>
Set up an agent with skills directory and filesystem backend for on-demand skill loading.
```typescript
import { createDeepAgent, FilesystemBackend } from "deepagents";
import { MemorySaver } from "@langchain/langgraph";
const agent = await createDeepAgent({
backend: new FilesystemBackend({ rootDir: ".", virtualMode: true }),
skills: ["./skills/"],
checkpointer: new MemorySaver()
});
const result = await agent.invoke({
messages: [{ role: "user", content: "Use the python-testing skill" }]
}, { configurable: { thread_id: "session-1" } });
store = InMemoryStore()
..."""
store.put( namespace=("filesystem",), key="/skills/python-testing/SKILL.md", value=create_file_data(skill_content) )
agent = create_deep_agent( backend=lambda rt: StoreBackend(rt), store=store, skills=["/skills/"] )
</python>
</ex-skills-with-store-backend>
<boundaries>
### What Agents CAN Configure
- Model selection and parameters
- Additional custom tools
- System prompt customization
- Backend storage strategy
- Which tools require approval
- Custom subagents with specialized tools
### What Agents CANNOT Configure
- Core middleware removal (TodoList, Filesystem, SubAgent always present)
- The write_todos, task, or filesystem tool names
- The SKILL.md frontmatter format
</boundaries>
<fix-checkpointer-for-interrupts>
<python>
Interrupts require a checkpointer.
```python
# WRONG
agent = create_deep_agent(interrupt_on={"write_file": True})
# CORRECT
agent = create_deep_agent(interrupt_on={"write_file": True}, checkpointer=MemorySaver())
// CORRECT const agent = await createDeepAgent({ interruptOn: { write_file: true }, checkpointer: new MemorySaver() });
</typescript>
</fix-checkpointer-for-interrupts>
<fix-store-for-memory>
<python>
StoreBackend requires a Store instance for persistent memory across threads.
```python
# WRONG
agent = create_deep_agent(backend=lambda rt: StoreBackend(rt))
# CORRECT
agent = create_deep_agent(backend=lambda rt: StoreBackend(rt), store=InMemoryStore())
// CORRECT const agent = await createDeepAgent({ backend: (config) => new StoreBackend(config), store: new InMemoryStore() });
</typescript>
</fix-store-for-memory>
<fix-thread-id-for-conversations>
<python>
Use consistent thread_id to maintain conversation context across invocations.
```python
# WRONG: Each invocation is isolated
agent.invoke({"messages": [{"role": "user", "content": "Hi"}]})
agent.invoke({"messages": [{"role": "user", "content": "What did I say?"}]})
# CORRECT
config = {"configurable": {"thread_id": "user-123"}}
agent.invoke({"messages": [...]}, config=config)
agent.invoke({"messages": [...]}, config=config)
// CORRECT const config = { configurable: { thread_id: "user-123" } }; await agent.invoke({ messages: [...] }, config); await agent.invoke({ messages: [...] }, config);
</typescript>
</fix-thread-id-for-conversations>
<fix-frontmatter-required>
```markdown
# WRONG: Missing frontmatter in SKILL.md
# My Skill
This is my skill...
# CORRECT: Include YAML frontmatter
---
name: my-skill
description: Python testing best practices with pytest fixtures and mocking
---
# My Skill
This is my skill...
agent = create_deep_agent( backend=FilesystemBackend(root_dir=".", virtual_mode=True), skills=["./skills/"] )
</python>
</fix-backend-for-skills>
<fix-specific-skill-descriptions>
Use specific descriptions to help agents decide when to use a skill.
```markdown
# WRONG: Vague description
---
name: helper
description: Helpful skill
---
# CORRECT: Specific description
---
name: python-testing
description: Python testing best practices with pytest fixtures, mocking, and async patterns
---
agent = create_deep_agent( skills=["/main-skills/"], subagents=[{"name": "helper", "skills": ["/helper-skills/"], ...}] )
</python>
</fix-subagent-skills>
Weekly Installs
2.3K
Repository
GitHub Stars
423
First Seen
Mar 3, 2026
Security Audits
Gen Agent Trust HubPassSocketPassSnykPass
Installed on
claude-code1.9K
codex1.8K
cursor1.8K
github-copilot1.8K
opencode1.8K
gemini-cli1.8K
React 组合模式指南:Vercel 组件架构最佳实践,提升代码可维护性
102,200 周安装