How create_deep_agent Integrates with LangGraph Checkpointing and Store
The create_deep_agent function integrates with LangGraph's persistence layer by accepting checkpointer and store parameters that it forwards directly to the underlying CompiledStateGraph, enabling stateful agent execution and cross-run data storage.
The create_deep_agent function in the langchain-ai/deepagents repository constructs sophisticated AI agents by building a LangGraph CompiledStateGraph. Understanding how create_deep_agent integrates with LangGraph checkpointing and store mechanisms is essential for production deployments requiring state persistence across sessions.
How create_deep_agent Handles Persistence Parameters
The function signature in libs/deepagents/deepagents/graph.py exposes two optional parameters that control LangGraph's persistence layer. The checkpointer parameter accepts a LangGraph Checkpointer instance that records the agent's state after each step, while the store parameter accepts a BaseStore for arbitrary key-value data persistence. According to the source code at lines 94-96, these parameters are defined as optional arguments in the public API.
When assembling the agent, create_deep_agent forwards these objects unchanged to the underlying create_agent function from LangChain. At lines 300-303 in graph.py, the function returns:
return create_agent(
model,
...,
checkpointer=checkpointer,
store=store,
...
)
This effectively passes the persistence configuration directly to the compiled graph. If omitted, LangGraph falls back to default in-memory checkpointing and a no-op store, meaning the agent cannot survive process restarts or share data across separate runs.
The Assembly Pipeline: Where Checkpointing Fits
The integration occurs at the final stage of a five-step assembly process:
- Model resolution – the LLM is prepared via
resolve_model(defined inlibs/deepagents/deepagents/_models.py). - Backend selection – a
StateBackendis chosen for filesystem-related tools. - Middleware composition – standard middlewares (todo list, filesystem, summarization, etc.) are assembled.
- Agent creation –
create_agentreceives the model, tools, middleware list, and the LangGraph persistence objects. - Graph configuration – recursion limits and metadata are applied before returning the compiled graph.
Because checkpointing and storage are plug-in points at the end of this pipeline, developers can configure state durability without modifying built-in middleware logic in libs/deepagents/deepagents/middleware/*.
Code Examples: Configuring Checkpointing and Storage
Basic Usage with Default In-Memory Checkpointing
from deepagents.graph import create_deep_agent
agent = create_deep_agent()
# Agent runs with ephemeral state; data is lost when the Python process ends.
Persistent Checkpointing with SQLite
from deepagents.graph import create_deep_agent
from langgraph.checkpoint.sql import SqlCheckpoint
from pathlib import Path
# Store checkpoints in a local SQLite file
checkpoint = SqlCheckpoint(
db_url=f"sqlite:///{Path('checkpoints.db')}"
)
agent = create_deep_agent(
checkpointer=checkpoint,
)
# The agent's state can now be resumed across sessions.
Custom Key-Value Storage with Redis
from deepagents.graph import create_deep_agent
from langgraph.store.redis import RedisStore
store = RedisStore(host="localhost", port=6379, db=0)
agent = create_deep_agent(
store=store,
)
# Middleware or tools can now read/write persistent data across runs.
Full Persistence Configuration
from deepagents.graph import create_deep_agent
from langgraph.checkpoint.sql import SqlCheckpoint
from langgraph.store.redis import RedisStore
agent = create_deep_agent(
checkpointer=SqlCheckpoint(db_url="sqlite:///agent_state.db"),
store=RedisStore(host="redis", port=6379),
)
# Both agent state and key-value data persist externally.
Key Source Files and Implementation Details
| File | Purpose |
|---|---|
libs/deepagents/deepagents/graph.py |
Core factory that assembles the Deep Agent and forwards checkpointer/store to LangGraph (lines 94-96, 300-303). |
libs/deepagents/deepagents/_models.py |
Resolves model strings to LangChain BaseChatModel instances before checkpointing begins. |
libs/deepagents/deepagents/middleware/* |
Middleware stack that runs before graph creation; operates independently of persistence but relies on the same backend infrastructure. |
Summary
create_deep_agentacceptscheckpointerandstoreparameters that map directly to LangGraph's persistence APIs- These parameters are forwarded unchanged to
create_agentat lines 300-303 ingraph.py - Omitting these parameters results in in-memory checkpointing that cannot survive process restarts
- The persistence layer acts as a plug-in point at the end of the agent assembly pipeline
- Developers can mix checkpoint implementations (SQLite, Redis, etc.) without modifying middleware logic
Frequently Asked Questions
What happens if I don't provide a checkpointer to create_deep_agent?
If omitted, LangGraph defaults to in-memory checkpointing. While this works for single-session agents, the state cannot be resumed after a process restart, making it unsuitable for production workflows requiring fault tolerance.
Can I use create_deep_agent with a custom store implementation?
Yes. The store parameter accepts any LangGraph BaseStore implementation. You can provide custom stores by implementing the BaseStore interface, allowing integration with proprietary databases or specialized caching layers.
How does the checkpointer parameter affect agent resumption?
The checkpointer records the agent's state after each graph step. When resuming, LangGraph uses this checkpoint to restore the exact execution state, enabling long-running agents to continue from interruption points without losing context.
Where are the checkpointer and store parameters defined in the source code?
These parameters appear in the function signature at lines 94-96 of libs/deepagents/deepagents/graph.py, where they are typed as optional Checkpointer and BaseStore instances respectively.
Have a question about this repo?
These articles cover the highlights, but your codebase questions are specific. Give your agent direct access to the source. Share this with your agent to get started:
curl -s "https://instagit.com/install.md" Maintain an open-source project? Get it listed too →