Quick Guide to LangChain DeepAgents: Core Features and Fast Onboarding

This article introduces the background and key advantages of the DeepAgents framework, explains its four core capabilities—task planning, context management, sub‑agent generation, and long‑term memory—and provides a step‑by‑step code example that builds a complex AI agent with just a few lines of Python.

Fun with Large Models
Fun with Large Models
Fun with Large Models
Quick Guide to LangChain DeepAgents: Core Features and Fast Onboarding

Why DeepAgents is needed

Using create_agent builds a ReAct graph where the agent repeatedly calls tools until a problem is solved. This simple loop limits the agent’s ability to plan and execute long‑running, complex tasks.

LangChain CEO Harrison Chase created DeepAgents by combining four capabilities—detailed prompts, task planning, sub‑agents, and a file‑system backend—to enable deeper reasoning. The framework has been open‑sourced and merged into the official LangChain library.

Core capabilities of DeepAgents

Planning and task decomposition – Built‑in TodoList and File System tools let the agent break a complex goal into discrete steps, track progress, and adjust the plan dynamically.

Context management – File System tools ( ls, read_file, write_file, edit_file) offload large context to external storage, preventing window overflow. The Summarization middleware compresses variable‑length tool results.

Sub‑agent generation – The Task tool enables the main agent to spawn dedicated sub‑agents for specific subtasks, keeping the main context clean while handling complex work.

Long‑term memory – Different backend implementations allow agents to persist information across threads and conversations, providing intelligent assistance based on past interactions.

Quick start: basic usage and core features

Positioning

The deepagents package provides create_deep_agent, a thin wrapper around create_agent that adds default middleware and configuration for complex tasks.

Use create_agent for simple, single‑step tasks.

Use create_deep_agent for multi‑step planning, extensive context handling, sub‑agent delegation, or persistent memory.

Environment setup

conda create -n langchaindeepagents python=3.12
conda activate langchaindeepagents
pip install -U deepagents

Project file

from dotenv import load_dotenv
from deepagents import create_deep_agent
from langchain_deepseek import ChatDeepSeek
from deepagents.backends import FilesystemBackend

load_dotenv()
model = ChatDeepSeek(model="deepseek-chat")

Agent construction

research_instruction = """
You are an expert in international relations, capable of analyzing national conditions and generating reports per user request.
"""

agent = create_deep_agent(
    model=model,
    tools=[],
    system_prompt=research_instruction,
    subagents=[],
    backend=FilesystemBackend(root_dir="./test_dir", virtual_mode=True)
)

Task execution

query = {"messages": [{"role": "user", "content": "Analyze Iran and the United States and write a ~1500‑word report on why they are antagonistic."}]}
for event in agent.stream(query, stream_mode="values"):
    # Simplified display logic (omitted for brevity)
    pass
print("
[bold green]Task completed![/bold green]
")

Execution process analysis

After receiving the query, the agent first calls the write_todos tool to generate a task plan.

The agent then follows the plan. Although no explicit subagents were provided, the agent detects that the analysis of Iran and the United States can be parallelized and automatically invokes the task tool to spawn two sub‑agents that run concurrently.

When a sub‑task finishes, the agent marks it as completed and continues iterating until the final report is produced.

Conclusion

DeepAgents adds planning, context management, sub‑agent parallelism, and persistent memory to LangChain agents, enabling the construction of sophisticated AI agents with only a few lines of code. The next article will explore sub‑agent creation, communication, and task delegation mechanisms in detail.

PythonAI agentsLangChainLangGraphDeepAgents
Fun with Large Models
Written by

Fun with Large Models

Master's graduate from Beijing Institute of Technology, published four top‑journal papers, previously worked as a developer at ByteDance and Alibaba. Currently researching large models at a major state‑owned enterprise. Committed to sharing concise, practical AI large‑model development experience, believing that AI large models will become as essential as PCs in the future. Let's start experimenting now!

0 followers
Reader feedback

How this landed with the community

Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.