Looking for the JS/TS version? Check out Deep Agents.js.
To help you ship LangChain apps to production faster, check out LangSmith. LangSmith is a unified developer platform for building, testing, and monitoring LLM applications.
pip install deepagents
# or
uv add deepagents
Using an LLM to call tools in a loop is the simplest form of an agent. This architecture, however, can yield agents that are "shallow" and fail to plan and act over longer, more complex tasks.
Applications like "Deep Research", "Manus", and "Claude Code" have gotten around this limitation by implementing a combination of four things: a planning tool, sub agents, access to a file system, and a detailed prompt.
deepagents is a Python package that implements these in a general purpose way so that you can easily create a Deep Agent for your application. For a full overview and quickstart of Deep Agents, the best resource is our docs.
Acknowledgements: This project was primarily inspired by Claude Code, and initially was largely an attempt to see what made Claude Code general purpose, and make it even more so.
See our Releases and Versioning policies.
As an open-source project in a rapidly developing field, we are extremely open to contributions, whether it be in the form of a new feature, improved infrastructure, or better documentation.
For detailed information on how to contribute, see the Contributing Guide.
Metadata for a skill per Agent Skills specification (https://agentskills.io/specification).
State for the skills middleware.
State update for the skills middleware.
Middleware for loading and exposing agent skills to the system prompt.
Specification for an agent.
A pre-compiled agent spec.
Middleware for providing subagents to an agent via a task tool.
Middleware to patch dangling tool calls in the messages history.
State schema for MemoryMiddleware.
State update for MemoryMiddleware.
Middleware for loading agent memory from AGENTS.md files.
Data structure for storing file contents with metadata.
State for the filesystem middleware.
Middleware for providing filesystem and optional execution tools to an agent.
Represents a summarization event.
Settings for truncating large tool arguments in old messages.
State for the summarization middleware.
Default settings computed from model profile.
Base sandbox implementation with execute() as abstract method.
Backend that stores files in agent state (ephemeral).
Result of a single file download operation.
Result of a single file upload operation.
Structured file listing info.
Structured grep match entry.
Result from backend write operations.
Result from backend edit operations.
Protocol for pluggable memory backends (single, unified).
Result of code execution.
Extension of BackendProtocol that adds shell command execution.
Filesystem backend with unrestricted local shell command execution.
Routes file operations to different backends by path prefix.
Context passed to namespace factory functions.
Backend that stores files in LangGraph's BaseStore (persistent).
Backend that reads and writes files directly from the filesystem.
Get the default model for deep agents.
Create a deep agent.
Append text to a system message.
Sanitize tool_call_id to prevent path traversal and separator issues.
Format file content with line numbers (cat -n style).
Check if content is empty and return warning message.
Convert FileData to plain string content.
Create a FileData object with timestamps.
Update FileData with new content, preserving creation timestamp.
Format file data for read response with line numbers.
Perform string replacement with occurrence validation.
Truncate list or string result if it exceeds token limit (rough estimate: 4 chars/token).
Validate and normalize file path for security.
Return structured grep matches from an in-memory files mapping.
Group structured matches into the legacy dict form used by formatters.
Format structured grep matches using existing formatting logic.
Check whether a backend class's execute accepts a timeout kwarg.
Deep Agents package.
Deep Agents come with planning, filesystem, and subagents.
Middleware for the agent.
Skills middleware for loading and exposing agent skills to the system prompt.
Middleware for providing subagents to an agent via a task tool.
Middleware to patch dangling tool calls in the messages history.
Middleware for loading agent memory/context from AGENTS.md files.
Middleware for providing filesystem tools to an agent.
Summarization middleware for offloading conversation history.
Memory backends for pluggable file storage.
Base sandbox implementation with execute() as the only abstract method.
Shared utility functions for memory backend implementations.
StateBackend: Store files in LangGraph agent state (ephemeral).
Protocol definition for pluggable memory backends.
LocalShellBackend: Filesystem backend with unrestricted local shell execution.
Composite backend that routes file operations by path prefix.
StoreBackend: Adapter for LangGraph's BaseStore (persistent, cross-thread).
FilesystemBackend: Read and write files directly from the filesystem.