Skip to main content
create_deep_agent has the following core configuration options:
For more information, see create_deep_agent.

Connection resilience

LangChain chat models automatically retry failed API requests with exponential backoff. By default, models retry up to 6 times for network errors, rate limits (429), and server errors (5xx). Client errors like 401 (unauthorized) or 404 are not retried. You can adjust the max_retries parameter when creating a model to tune this behavior for your environment:
For long-running agent tasks on unreliable networks, consider increasing max_retries to 10–15 and pairing it with a checkpointer so that progress is preserved across failures.

Model

By default, deepagents uses claude-sonnet-4-6. You can customize the model by passing any supported or LangChain model object.
Use the provider:model format (for example openai:gpt-5) to quickly switch between models.
👉 Read the OpenAI chat model integration docs

Tools

In addition to built-in tools for planning, file management, and subagent spawning, you can provide custom tools:

System prompt

Deep agents come with a built-in system prompt. The default system prompt contains detailed instructions for using the built-in planning tool, file system tools, and subagents. When middleware add special tools, like the filesystem tools, it appends them to the system prompt. Each deep agent should also include a custom system prompt specific to its specific use case:

Middleware

By default, deep agents have access to the following middleware:
  • TodoListMiddleware: Tracks and manages todo lists for organizing agent tasks and work
  • FilesystemMiddleware: Handles file system operations such as reading, writing, and navigating directories
  • SubAgentMiddleware: Spawns and coordinates subagents for delegating tasks to specialized agents
  • SummarizationMiddleware: Condenses message history to stay within context limits when conversations grow long
  • AnthropicPromptCachingMiddleware: Automatic reduction of redundant token processing when using Anthropic models
  • PatchToolCallsMiddleware: Automatic message history fixes when tool calls are interrupted or cancelled before receiving results
If you are using memory, skills, or human-in-the-loop, the following middleware is also included:
  • MemoryMiddleware: Persists and retrieves conversation context across sessions when the memory argument is provided
  • SkillsMiddleware: Enables custom skills when the skills argument is provided
  • HumanInTheLoopMiddleware: Pauses for human approval or input at specified points when the interrupt_on argument is provided
You can provide additional middleware to extend functionality, add tools, or implement custom hooks:
Do not mutate attributes after initializationIf you need to track values across hook invocations (for example, counters or accumulated data), use graph state. Graph state is scoped to a thread by design, so updates are safe under concurrency.Do this:
Do not do this:
Mutation in place—such as modifying self.x in before_agent or other hooks—can lead to subtle bugs and race conditions, because many operations run concurrently (subagents, parallel tools, and parallel invocations on different threads).For full details on extending state with custom properties, see Custom middleware - Custom state schema. If you must use mutation in custom middleware, consider what happens when subagents, parallel tools, or concurrent agent invocations run at the same time.

Subagents

To isolate detailed work and avoid context bloat, use subagents:
For more information, see Subagents.

Backends

Deep agent tools can make use of virtual file systems to store, access, and edit files. By default, deep agents use a StateBackend. If you are using skills or memory, you must add the expected skill or memory files to the backend before creating the agent.
An ephemeral filesystem backend stored in langgraph state.This filesystem only persists for a single thread.
For more information, see Backends.

Sandboxes

Sandboxes are specialized backends that run agent code in an isolated environment with their own filesystem and an execute tool for shell commands. Use a sandbox backend when you want your deep agent to write files, install dependencies, and run commands without changing anything on your local machine. You configure sandboxes by passing a sandbox backend to backend when creating your deep agent: For more information, see Sandboxes.

Human-in-the-loop

Some tool operations may be sensitive and require human approval before execution. You can configure the approval for each tool:
You can configure interrupt for agents and subagents on tool call as well as from within tool calls. For more information, see Human-in-the-loop.

Skills

You can use skills to provide your deep agent with new capabilities and expertise. While tools tend to cover lower level functionality like native file system actions or planning, skills can contain detailed instructions on how to complete tasks, reference info, and other assets, such as templates. These files are only loaded by the agent when the agent has determined that the skill is useful for the current prompt. This progressive disclosure reduces the amount of tokens and context the agent has to consider upon startup. For example skills, see Deep Agent example skills. To add skills to your deep agent, pass them as an argument to create_deep_agent:

Memory

Use AGENTS.md files to provide extra context to your deep agent. You can pass one or more file paths to the memory parameter when creating your deep agent:

Structured ouput

Deep agents support structured ouput. You can set a desired structured output schema by passing it as the response_format argument to the call to create_deep_agent(). When the model generates the structured data, it’s captured, validated, and returned in the ‘structured_response’ key of the deep agent’s state.
For more information and examples, see response format.