- A planning tool
- A filesystem for storing context and long-term memories
- The ability to spawn subagents
create_deep_agent
, we automatically attach TodoListMiddleware
, FilesystemMiddleware
, and SubAgentMiddleware
to your agent.
Middleware is composable—you can add as many or as few middleware to an agent as needed. You can use any middleware independently.
The following sections explain what each middleware provides.
Planning middleware
Planning is integral to solving complex problems. If you’ve used Claude Code recently, you’ll notice how it writes out a to-do list before tackling complex, multi-part tasks. You’ll also notice how it can adapt and update this to-do list on the fly as more information comes in.TodoListMiddleware
provides your agent with a tool specifically for updating this to-do list. Before and while it executes a multi-part task, the agent is prompted to use the write_todos
tool to keep track of what it’s doing and what still needs to be done.
Filesystem middleware
Context engineering is a main challenge in building effective agents. This is particularly difficult when using tools that return variable-length results (for example, web_search and rag), as long tool results can quickly fill your context window.FilesystemMiddleware
provides four tools for interacting with both short-term and long-term memory:
- ls: List the files in the filesystem
- read_file: Read an entire file or a certain number of lines from a file
- write_file: Write a new file to the filesystem
- edit_file: Edit an existing file in the filesystem
Short-term vs. long-term filesystem
By default, these tools write to a local “filesystem” in your graph state. If you provide aStore
object to your agent runtime, you can also enable saving to long-term memory, which persists across different threads of your agent.
use_longterm_memory=True
and provide a Store
in your agent runtime, then any files prefixed with /memories/ are saved to the long-term memory store. Note that any agents deployed on LangGraph Platform are automatically provided with a long-term memory store.
Subagent middleware
Handing off tasks to subagents isolates context, keeping the main (supervisor) agent’s context window clean while still going deep on a task. The subagents middleware allows you to supply subagents through atask
tool.
general-purpose
subagent at all times. This subagent has the same instructions as the main agent and all the tools it has access to. The primary purpose of the general-purpose
subagent is context isolation—the main agent can delegate a complex task to this subagent and get a concise answer back without bloat from intermediate tool calls.
Connect these docs to Claude, VSCode, and more via MCP for real-time answers. See how