Chapter 9 · Deep Agents Introduction: create_deep_agent
Chapter goals:
- Understand Deep Agents positioning: Agent Harness above LangGraph
- Master basic usage of create_deep_agent()
- Learn to configure multiple Providers (OpenAI, Anthropic, Google)
- Understand basic concepts of Skills and Memory
9.1 What is Deep Agents?
Deep Agents is an Agent Harness provided by LangChain, offering on top of LangGraph:
- Simplified API (create Agent in one line of code)
- Built-in context management
- Filesystem tools
- Sub-agent support
- Memory system
Comparison: LangGraph is Runtime, Deep Agents is Harness (Harness layer)
9.2 Quick Start
from deepagents import create_deep_agent
# Create agent with one line
agent = create_deep_agent(
model="gpt-4o",
tools=["search", "code", "filesystem"],
memory=True
)
# Run agent
result = agent.run("Research and summarize this topic")9.2.1 Provider Configuration
from deepagents import create_deep_agent
from deepagents.providers import OpenAIProvider, AnthropicProvider, GoogleProvider
# Multiple providers
agent = create_deep_agent(
providers=[
OpenAIProvider(api_key="sk-..."),
AnthropicProvider(api_key="sk-ant-..."),
GoogleProvider(api_key="AIza..."),
],
default_provider="openai"
)9.3 Skills System
Skills are reusable Agent capabilities and instructions:
<!-- .deepagents/skills/researcher/AGENTS.md -->
---
name: researcher
description: Research topics and generate reports
model: anthropic:claude-haiku-4-5-20251001
---
You are a research assistant. Your tasks:
1. Search for relevant information
2. Synthesize findings
3. Generate structured report9.3.1 Loading Skills
from deepagents import load_skills
skills = load_skills(".deepagents/skills/")
agent = create_deep_agent(skills=skills)9.4 Memory System
9.4.1 Short-term Memory
Conversation history within a session:
agent = create_deep_agent(
memory="short_term", # Last N messages
memory_window=10
)9.4.2 Long-term Memory
Persistent memory across sessions:
agent = create_deep_agent(
memory="long_term",
memory_store="sqlite:///memory.db"
)9.5 Approval Modes
Three approval modes for human-in-the-loop:
| Mode | Behavior |
|---|---|
Manual | Every tool call requires approval |
Auto | Auto-approve safe operations |
YOLO | No approval, maximum autonomy |
agent = create_deep_agent(
approval_mode="manual", # or "auto" or "yolo"
allowed_tools=["read_file", "search"]
)Chapter Summary
- Deep Agents: High-level Harness built on LangGraph;
- create_deep_agent(): One-line Agent creation with configurable providers;
- Skills: Reusable capabilities defined in AGENTS.md;
- Memory: Short-term (session) and long-term (persistent) options;
- Approval Modes: Manual, Auto, YOLO for human oversight control.
🛠️ Hands-on Practice
Create a Deep Agent with multiple provider fallback (OpenAI → Anthropic → Google).
Define custom Skills in AGENTS.md format and load them into an Agent.
Implement human approval workflow with Manual mode for sensitive operations.
🧪 随堂测验
点击你认为正确的选项。答错时会展示正确答案与原因解析。
1. What is Deep Agents in relation to LangGraph?
2. How do you create a Deep Agent?
3. What are Skills in Deep Agents?
4. Which approval mode gives maximum Agent autonomy?