LangChain Reference home pageLangChain ReferenceLangChain Reference
  • GitHub
  • Main Docs
Deep Agents
LangChain
LangGraph
Integrations
LangSmith
  • Overview
  • Agent
  • Middleware
  • Backends
  • Sandboxes
  • Skills
  • Subagents
  • Types
Modal
Daytona
Deno
Node VFS
Sandbox Standard Tests
  • Vitest
⌘I

LangChain Assistant

Ask a question to get started

Enter to send•Shift+Enter new line

Menu

OverviewAgentMiddlewareBackendsSandboxesSkillsSubagentsTypes
Modal
Daytona
Deno
Node VFS
Sandbox Standard Tests
Vitest
Language
Theme
JavaScriptdeepagents

deepagents

Description

Deep Agents Logo Deep Agents Logo

The batteries-included agent harness.

npm version License: MIT TypeScript Twitter / X

Deep Agents is an agent harness. An opinionated, ready-to-run agent out of the box. Instead of wiring prompts, tools, and context management yourself, you get a working agent immediately and customize what you need.

What's included:

  • Planning — write_todos for task breakdown and progress tracking
  • Filesystem — read_file, write_file, edit_file, ls, glob, grep for working memory
  • Sub-agents — task for delegating work with isolated context windows
  • Smart defaults — built-in prompt and middleware that make these tools useful out of the box
  • Context management — file-based workflows to keep long tasks manageable

[!NOTE] Looking for the Python package? See langchain-ai/deepagents.

Quickstart

npm install deepagents
# or
pnpm add deepagents
# or
yarn add deepagents
import { createDeepAgent } from "deepagents";

const agent = createDeepAgent();

const result = await agent.invoke({
  messages: [
    {
      role: "user",
      content: "Research LangGraph and write a summary in summary.md",
    },
  ],
});

The agent can plan, read/write files, and manage longer tasks with sub-agents and filesystem tools.

[!TIP] For developing, debugging, and deploying AI agents and LLM applications, see LangSmith.

Customization

Add tools, swap models, and customize prompts as needed:

import { ChatOpenAI } from "@langchain/openai";
import { createDeepAgent } from "deepagents";

const agent = createDeepAgent({
  model: new ChatOpenAI({ model: "gpt-5", temperature: 0 }),
  tools: [myCustomTool],
  systemPrompt: "You are a research assistant.",
});

See the JavaScript Deep Agents docs for full configuration options.

LangGraph Native

createDeepAgent returns a compiled LangGraph graph, so you can use streaming, Studio, checkpointers, and other LangGraph features.

Why Use It

  • 100% open source — MIT licensed and extensible
  • Provider agnostic — works with tool-calling chat models
  • Built on LangGraph — production runtime with streaming and persistence
  • Batteries included — planning, file access, sub-agents, and defaults out of the box
  • Fast to start — install and run with sensible defaults
  • Easy to customize — add tools/models/prompts when you need to

Documentation

  • docs.langchain.com - Concepts and guides
  • Examples - Working agents and patterns
  • LangChain Forum - Community discussion and support

Security

Deep Agents follows a "trust the LLM" model. The agent can do anything its tools allow. Enforce boundaries at the tool/sandbox level, not by expecting the model to self-police. See the security policy for more information.

Classes

Class

BaseSandbox

Base sandbox implementation with execute() as the only abstract method.

Class

CompositeBackend

Backend that routes file operations to different backends based on path prefix.

Class

FilesystemBackend

Backend that reads and writes files directly from the filesystem.

Class

LangSmithSandbox

LangSmith Sandbox backend for deepagents.

Class

LocalShellBackend

Filesystem backend with unrestricted local shell command execution.

Class

SandboxError

Custom error class for sandbox operations.

Class

StateBackend

Backend that stores files in agent state (ephemeral).

Class

StoreBackend

Backend that stores files in LangGraph's BaseStore (persistent).

Class

ConfigurationError

Thrown when createDeepAgent receives invalid configuration.

Class

BaseSandbox

Base sandbox implementation with execute() as the only abstract method.

Class

CompositeBackend

Backend that routes file operations to different backends based on path prefix.

Class

FilesystemBackend

Backend that reads and writes files directly from the filesystem.

Class

LangSmithSandbox

LangSmith Sandbox backend for deepagents.

Class

LocalShellBackend

Filesystem backend with unrestricted local shell command execution.

Class

SandboxError

Custom error class for sandbox operations.

Class

StateBackend

Backend that stores files in agent state (ephemeral).

Class

StoreBackend

Backend that stores files in LangGraph's BaseStore (persistent).

Class

ConfigurationError

Thrown when createDeepAgent receives invalid configuration.

Functions

Function

createDeepAgent

Create a Deep Agent.

Function

isAnthropicModel

Detect whether a model is an Anthropic model.

Function

adaptBackendProtocol

Adapt a v1 BackendProtocol to BackendProtocolV2.

Function

adaptSandboxProtocol

Adapt a sandbox backend from v1 to v2 interface.

Function

buildGrepResultsDict

Group structured matches into the legacy dict form used by formatters.

Function

checkEmptyContent

Check if content is empty and return warning message.

Function

createFileData

Create a FileData object.

Function

fileDataToString

Convert FileData to plain string content.

Function

formatContentWithLineNumbers

Format file content with line numbers (cat -n style).

Function

formatGrepMatches

Format structured grep matches using existing formatting logic.

Function

formatGrepResults

Format grep search results based on output mode.

Function

formatReadResponse

Format file data for read response with line numbers.

Function

getMimeType

Determine MIME type from a file path's extension.

Function

globSearchFiles

Search files dict for paths matching glob pattern.

Function

grepMatchesFromFiles

Return structured grep matches from an in-memory files mapping.

Function

grepSearchFiles

Search file contents for literal text pattern.

Function

isFileDataBinary

Type guard to check if FileData contains binary content (Uint8Array).

Function

isFileDataV1

Type guard to check if FileData is v1 format (content as line array).

Function

isTextMimeType

Check whether a MIME type represents text content.

Function

migrateToFileDataV2

Convert FileData to v2 format, joining v1 line arrays into a single string.

Function

performStringReplacement

Perform string replacement with occurrence validation.

Function

sanitizeToolCallId

Sanitize tool_call_id to prevent path traversal and separator issues.

Function

truncateIfTooLong

Truncate list or string result if it exceeds token limit (rough estimate: 4 chars/token).

Function

updateFileData

Update FileData with new content, preserving creation timestamp.

Function

validateFilePath

Validate and normalize a file path for security.

Function

validatePath

Validate and normalize a directory path.

Function

isSandboxBackend

Type guard to check if a backend supports execution.

Function

isSandboxProtocol

Type guard to check if a backend is a sandbox protocol (v1 or v2).

Function

createSettings

Create a Settings instance with detected environment.

Function

findProjectRoot

Find the project root by looking for .git directory.

Function

computeSummarizationDefaults

Compute summarization defaults based on model profile.

Function

createAsyncSubAgentMiddleware

Function

createCompletionCallbackMiddleware

Create a completion callback middleware for async subagents.

Function

createFilesystemMiddleware

Create filesystem middleware with all tools and features.

Function

createMemoryMiddleware

Create middleware for loading agent memory from AGENTS.md files.

Function

createPatchToolCallsMiddleware

Create middleware that enforces strict tool call / tool response parity in

Function

createSkillsMiddleware

Create backend-agnostic middleware for loading and exposing agent skills.

Function

createSubAgentMiddleware

Create subagent middleware with task tool

Function

createSummarizationMiddleware

Create summarization middleware with backend support for conversation history offloading.

Function

isAsyncSubAgent

Type guard to distinguish async SubAgents from sync SubAgents/CompiledSubAgents.

Function

isSandboxBackend

Type guard to check if a backend supports execution.

Function

isSandboxProtocol

Type guard to check if a backend is a sandbox protocol (v1 or v2).

Function

listSkills

List skills from user and/or project directories.

Function

parseSkillMetadata

Parse YAML frontmatter from a SKILL.md file per Agent Skills spec.

Function

adaptBackendProtocol

Adapt a v1 BackendProtocol to BackendProtocolV2.

Function

adaptSandboxProtocol

Adapt a sandbox backend from v1 to v2 interface.

Function

createDeepAgent

Create a Deep Agent.

Function

createSettings

Create a Settings instance with detected environment.

Function

findProjectRoot

Find the project root by looking for .git directory.

Function

appendToSystemMessage

Append text to a system message.

Function

createContentPreview

Create a preview of content showing head and tail with truncation marker.

Function

patchDanglingToolCalls

Patch tool call / tool response parity in a messages array.

Function

prependToSystemMessage

Prepend text to a system message.

Function

computeSummarizationDefaults

Compute summarization defaults based on model profile.

Function

createAsyncSubAgentMiddleware

Function

createCompletionCallbackMiddleware

Create a completion callback middleware for async subagents.

Function

createFilesystemMiddleware

Create filesystem middleware with all tools and features.

Function

createMemoryMiddleware

Create middleware for loading agent memory from AGENTS.md files.

Function

createPatchToolCallsMiddleware

Create middleware that enforces strict tool call / tool response parity in

Function

createSkillsMiddleware

Create backend-agnostic middleware for loading and exposing agent skills.

Function

createSubAgentMiddleware

Create subagent middleware with task tool

Function

createSummarizationMiddleware

Create summarization middleware with backend support for conversation history offloading.

Function

isAsyncSubAgent

Type guard to distinguish async SubAgents from sync SubAgents/CompiledSubAgents.

Function

listSkills

List skills from user and/or project directories.

Function

parseSkillMetadata

Parse YAML frontmatter from a SKILL.md file per Agent Skills spec.

Function

createAgentMemoryMiddleware

deprecated

Create middleware for loading agent-specific long-term memory.

Interfaces

Types

Interface

LangSmithSandboxCreateOptions

Options for the LangSmithSandbox.create() static factory.

Interface

BackendProtocolV2

Updated protocol for pluggable memory backends.

Interface

EditResult

Result from backend edit operations.

Interface

ExecuteResponse

Result of code execution.

Interface

FileDownloadResponse

Result of a single file download operation.

Interface

FileInfo

Structured file listing info.

Interface

FileUploadResponse

Result of a single file upload operation.

Interface

GlobResult

Structured result from backend glob operations.

Interface

GrepMatch

Structured grep match entry.

Interface

GrepResult

Structured result from grep/search operations.

Interface

LangSmithSandboxOptions

Options for constructing a LangSmithSandbox from an existing Sandbox instance.

Interface

LocalShellBackendOptions

Options for creating a LocalShellBackend instance.

Interface

LsResult

Structured result from backend ls operations.

Interface

ReadRawResult

Structured result from backend readRaw operations.

Interface

ReadResult

Structured result from backend read operations.

Interface

SandboxBackendProtocolV2

Protocol for sandboxed backends with isolated runtime.

Interface

SandboxDeleteOptions

Options for deleting a sandbox.

Interface

SandboxGetOrCreateOptions

Options for getting or creating a sandbox.

Interface

SandboxInfo

Metadata for a single sandbox instance.

Interface

SandboxListOptions

Options for listing sandboxes.

Interface

SandboxListResponse

Paginated response from a sandbox list operation.

Interface

StoreBackendContext

Context provided to dynamic namespace factory functions.

Interface

StoreBackendOptions

Options for StoreBackend constructor.

Interface

WriteResult

Result from backend write operations.

Interface

Settings

Settings interface for project detection and path management.

Interface

SettingsOptions

Options for creating a Settings instance.

Interface

AgentMemoryMiddlewareOptions

Options for the agent memory middleware.

Interface

AsyncSubAgent

Specification for an async subagent running on a remote Agent Protocol

Interface

AsyncSubAgentMiddlewareOptions

Options for creating async subagent middleware.

Interface

AsyncTask

A tracked async subagent task persisted in agent state.

Interface

BackendProtocolV2

Updated protocol for pluggable memory backends.

Interface

CompiledSubAgent

Type definitions for pre-compiled agents.

Interface

CompletionCallbackOptions

Options for creating the completion callback middleware.

Interface

EditResult

Result from backend edit operations.

Interface

ExecuteResponse

Result of code execution.

Interface

FileDownloadResponse

Result of a single file download operation.

Interface

FileInfo

Structured file listing info.

Interface

FilesystemMiddlewareOptions

Options for creating filesystem middleware.

Interface

FileUploadResponse

Result of a single file upload operation.

Interface

GlobResult

Structured result from backend glob operations.

Interface

GrepMatch

Structured grep match entry.

Interface

GrepResult

Structured result from grep/search operations.

Interface

LangSmithSandboxOptions

Options for constructing a LangSmithSandbox from an existing Sandbox instance.

Interface

ListSkillsOptions

Options for listing skills.

Interface

LoaderSkillMetadata

Metadata for a skill per Agent Skills spec.

Interface

LocalShellBackendOptions

Options for creating a LocalShellBackend instance.

Interface

LsResult

Structured result from backend ls operations.

Interface

MemoryMiddlewareOptions

Options for the memory middleware.

Interface

ReadRawResult

Structured result from backend readRaw operations.

Interface

ReadResult

Structured result from backend read operations.

Interface

SandboxBackendProtocolV2

Protocol for sandboxed backends with isolated runtime.

Interface

SandboxDeleteOptions

Options for deleting a sandbox.

Interface

SandboxGetOrCreateOptions

Options for getting or creating a sandbox.

Interface

SandboxInfo

Metadata for a single sandbox instance.

Interface

SandboxListOptions

Options for listing sandboxes.

Interface

SandboxListResponse

Paginated response from a sandbox list operation.

Interface

SkillMetadata

Metadata for a skill per Agent Skills specification.

Interface

SkillsMiddlewareOptions

Options for the skills middleware.

Interface

StoreBackendContext

Context provided to dynamic namespace factory functions.

Interface

StoreBackendOptions

Options for StoreBackend constructor.

Interface

SubAgent

Specification for a subagent that can be dynamically created.

Interface

SubAgentMiddlewareOptions

Options for creating subagent middleware

Interface

WriteResult

Result from backend write operations.

Interface

CreateDeepAgentParams

Configuration parameters for creating a Deep Agent

Interface

DeepAgentTypeConfig

Type bag that extends AgentTypeConfig with subagent type information.

Interface

DefaultDeepAgentTypeConfig

Default type configuration for deep agents.

Interface

Settings

Settings interface for project detection and path management.

Interface

SettingsOptions

Options for creating a Settings instance.

Interface

ContextSize

Context size specification for summarization triggers and retention policies.

Interface

SummarizationMiddlewareOptions

Options for the summarization middleware.

Interface

TruncateArgsSettings

Settings for truncating large tool arguments in old messages.

Interface

AsyncSubAgent

Specification for an async subagent running on a remote Agent Protocol

Interface

AsyncSubAgentMiddlewareOptions

Options for creating async subagent middleware.

Interface

AsyncTask

A tracked async subagent task persisted in agent state.

Interface

CompiledSubAgent

Type definitions for pre-compiled agents.

Interface

CompletionCallbackOptions

Options for creating the completion callback middleware.

Interface

FilesystemMiddlewareOptions

Options for creating filesystem middleware.

Interface

MemoryMiddlewareOptions

Options for the memory middleware.

Interface

SkillMetadata

Metadata for a skill per Agent Skills specification.

Interface

SkillsMiddlewareOptions

Options for the skills middleware.

Interface

SubAgent

Specification for a subagent that can be dynamically created.

Interface

SubAgentMiddlewareOptions

Options for creating subagent middleware

Interface

ListSkillsOptions

Options for listing skills.

Interface

SkillMetadata

Metadata for a skill per Agent Skills spec.

Interface

CreateDeepAgentParams

Configuration parameters for creating a Deep Agent

Interface

DeepAgentTypeConfig

Type bag that extends AgentTypeConfig with subagent type information.

Interface

DefaultDeepAgentTypeConfig

Default type configuration for deep agents.

Interface

BackendProtocol

deprecated
Interface

BackendProtocolV1

deprecated

Protocol for pluggable memory backends (single, unified).

Interface

BackendRuntime

deprecated

Agent Runtime with state

Interface

SandboxBackendProtocol

deprecated
Interface

SandboxBackendProtocolV1

deprecated

Protocol for sandboxed backends with isolated runtime.

Interface

StateAndStore

deprecated

State and store container for backend initialization.

Interface

BackendProtocol

deprecated
Interface

BackendProtocolV1

deprecated

Protocol for pluggable memory backends (single, unified).

Interface

BackendRuntime

deprecated

Agent Runtime with state

Interface

SandboxBackendProtocol

deprecated
Interface

SandboxBackendProtocolV1

deprecated

Protocol for sandboxed backends with isolated runtime.

Interface

StateAndStore

deprecated

State and store container for backend initialization.

Type

AnyBackendProtocol

Union of v1 and v2 backend protocols.

Type

FileData

Union of v1 and v2 file data formats.

Type

FileOperationError

Standardized error codes for file upload/download operations.

Type

MaybePromise

Type

SandboxErrorCode

Common error codes shared across all sandbox provider implementations.

Type

StoreBackendNamespaceFactory

Type

ConfigurationErrorCode

Error codes for ConfigurationError.

Type

AnyBackendProtocol

Union of v1 and v2 backend protocols.

Type

AsyncTaskStatus

Possible statuses for an async subagent task.

Type

FileData

Union of v1 and v2 file data formats.

Type

FileOperationError

Standardized error codes for file upload/download operations.

Type

MaybePromise

Type

SandboxErrorCode

Common error codes shared across all sandbox provider implementations.

Type

StoreBackendNamespaceFactory

Type

AnySubAgent

Any subagent specification — sync, compiled, or async.

Type

ConfigurationErrorCode

Error codes for ConfigurationError.

Type

DeepAgent

DeepAgent extends ReactAgent with additional subagent type information.

Type

ExtractSubAgentMiddleware

Helper type to extract middleware from a SubAgent definition

Type

FlattenSubAgentMiddleware

Helper type to flatten and merge middleware from all subagents

Type

InferDeepAgentSubagents

Shorthand helper to extract the Subagents type from a DeepAgentTypeConfig or DeepAgent.

Type

InferDeepAgentType

Helper type to extract any property from a DeepAgentTypeConfig or DeepAgent.

Type

InferStructuredResponse

Utility type to extract the parsed response type from a ResponseFormat strategy.

Type

InferSubagentByName

Helper type to extract a subagent by name from a DeepAgent.

Type

InferSubAgentMiddlewareStates

Helper type to merge states from subagent middleware

Type

InferSubagentReactAgentType

Helper type to extract the ReactAgent type from a subagent definition.

Type

MergedDeepAgentState

Combined state type including custom middleware and subagent middleware states

Type

ResolveDeepAgentTypeConfig

Helper type to resolve a DeepAgentTypeConfig from either:

Type

SupportedResponseFormat

Union of all response format types accepted by createDeepAgent.

Type

SummarizationEvent

Represents a summarization event that tracks what was summarized and where the cutoff is.

Type

AsyncTaskStatus

Possible statuses for an async subagent task.

Type

AnySubAgent

Any subagent specification — sync, compiled, or async.

Type

DeepAgent

DeepAgent extends ReactAgent with additional subagent type information.

Type

ExtractSubAgentMiddleware

Helper type to extract middleware from a SubAgent definition

Type

FlattenSubAgentMiddleware

Helper type to flatten and merge middleware from all subagents

Type

InferCompiledSubagents

Helper type to extract CompiledSubAgent (subagents with runnable) from a DeepAgent.

Type

InferDeepAgentSubagents

Shorthand helper to extract the Subagents type from a DeepAgentTypeConfig or DeepAgent.

Type

InferDeepAgentType

Helper type to extract any property from a DeepAgentTypeConfig or DeepAgent.

Type

InferRegularSubagents

Helper type to extract SubAgent (subagents with middleware) from a DeepAgent.

Type

InferStructuredResponse

Utility type to extract the parsed response type from a ResponseFormat strategy.

Type

InferSubagentByName

Helper type to extract a subagent by name from a DeepAgent.

Type

InferSubAgentMiddlewareStates

Helper type to merge states from subagent middleware

Type

InferSubagentReactAgentType

Helper type to extract the ReactAgent type from a subagent definition.

Type

MergedDeepAgentState

Combined state type including custom middleware and subagent middleware states

Type

ResolveDeepAgentTypeConfig

Helper type to resolve a DeepAgentTypeConfig from either:

Type

SupportedResponseFormat

Union of all response format types accepted by createDeepAgent.

Type

BackendFactory

deprecated

Factory function type for creating backend instances.

Type

BackendFactory

deprecated

Factory function type for creating backend instances.