Deep Agents is LangChain's batteries-included agent harness for long-running, high-context work — deep research, whole-codebase engineering, multi-step workflows that outrun a single context window. It bundles the scaffolding that makes tools like Claude Code and Codex effective — planning, sub-agents, a virtual filesystem, and context compaction — into one MIT-licensed library that runs on any tool-calling model. It is not a competitor to LangGraph; it is built on it. pip install deepagents, create_deep_agent(), done.
Deep Agents starts from a specific observation: the capability you feel when you use Claude Code or Codex doesn't come from the raw model. It comes from the scaffolding around it — the system prompt, a planning tool, a filesystem, the ability to spin up sub-agents, and a way to compress the conversation before it overflows. LangChain calls that scaffolding an agent harness, and Deep Agents is the open-source, model-agnostic extraction of exactly that pattern. Point it at any LLM that supports tool calling — frontier API, open-weight, or local — and you get the Claude Code shape without being tied to one vendor's runtime.
The most important thing to get right about Deep Agents is where it sits, because it is easy to mistake for a rival to its own foundation. LangChain states the stack plainly: LangGraph is the graph runtime; create_agent is a minimal agent harness on top of it; Deep Agents is a more opinionated harness on top of create_agent. Same building blocks all the way down — Deep Agents just makes the batteries-included choices so you don't have to assemble them yourself.
The graph runtime. Streaming, checkpointing, persistence, human-in-the-loop interrupts. Everything above inherits these for free.
create_agentLangChain's lightweight tool-calling loop with middleware hooks. Enough to build a standard agent; you add the rest.
Planning, sub-agents, filesystem, and compaction wired in by default. The batteries-included choice for long-horizon tasks.
A harness is everything wrapped around the core LLM-plus-tool-calling loop that turns a capable model into a capable agent: the system prompt, a way to plan and track steps, a place to write intermediate results, a mechanism to delegate sub-tasks, and a strategy for keeping the context window from overflowing on a long job. LangChain's own term of art — from its "Anatomy of an Agent Harness" post — and Deep Agents is a concrete, opinionated implementation of it. The word matters because it names the layer where the real engineering now lives: not in the model, in the scaffolding.
Deep Agents is the sum of four harness mechanisms, each shipped as LangChain middleware you can inspect, swap, or disable: planning, sub-agents, a virtual filesystem, and context compaction. The two-line factory below wires all four in; everything after it is detail on what each one does.
from deepagents import create_deep_agent # any tool-calling model: frontier, open-weight, or local agent = create_deep_agent( model="anthropic:claude-sonnet-4-6", tools=[web_search], system_prompt="You are an expert researcher.", ) result = agent.invoke({"messages": [("user", "Brief me on OKF adoption.")]})
1 · Planning — the write_todos tool (TodoListMiddleware). The agent maintains a stateful todo list — each item pending, in_progress, or completed — persisted in agent state rather than left implicit in the chat history. On a long task, the plan survives context compaction and keeps the agent oriented.
2 · Sub-agents — the task tool (SubAgentMiddleware). The main agent spawns an ephemeral, stateless sub-agent with a fresh, isolated context to do one piece of work, then hands back a compact summary. The point is token economy: the noisy middle of a sub-task — dozens of tool calls, large intermediate results — never pollutes the parent's context. Only the conclusion returns.
3 · Filesystem — ls, read_file, write_file, edit_file, glob, grep (FilesystemMiddleware). A virtual filesystem the agent reads and writes, backed by in-memory state, a LangGraph store, or real local disk. Its load-bearing job is offloading: large tool results are written to a file and referenced by path instead of being kept inline, so a single big search result can't blow the context budget. The agent pulls back only the slice it needs, when it needs it.
4 · Context compaction — summarization middleware. Long threads get compressed: recent messages are retained, everything before is replaced with a summary. This is where a genuinely new capability shipped — and the distinction is worth being precise about.
Threshold-based (the classic). The harness watches the context window and compacts when usage crosses a fixed line. It works, but it's blunt: it can fire in the middle of a delicate multi-step operation, or hold on too long right up to the limit.
Autonomous (the newer mode). LangChain's autonomous context compression (announced March 2026) gives the model a compact_conversation tool and lets it decide when to compress — at a task boundary, after extracting results from a large context, before starting something complex. It's gated so it can't fire too early (eligibility kicks in around half the auto-summarization trigger) and retains roughly the last 10% of context while summarizing the rest. It is opt-in in the SDK and on by default in the deepagents CLI. The shift — from the harness deciding when to the model deciding — is the editorially interesting part; LangChain frames it as letting the reasoning model manage its own memory.
You'll see the classic threshold cited as "around 85% of the window" in some write-ups and as a "~170K-token auto-summarization trigger" in one Deep Agents configuration. These describe different mechanisms and different runs, not a single canonical figure. The honest statement is: fixed-threshold compaction fires at some configured point near the window's limit — and that bluntness is precisely the brittleness the autonomous tool was built to fix. Treat any specific percentage as configuration, not spec.
Deep Agents inherits LangGraph's runtime (streaming, checkpointing, persistence) and LangSmith's tracing and evaluation. It ships in two shapes: a library you embed, and a CLI that adds the surrounding tooling a real agent workflow needs.
The MIT-licensed harness itself, in Python and TypeScript. create_deep_agent() and the four middleware. Embed it in your own app.
Adds web search, remote sandboxes, persistent memory, custom skills, and human-in-the-loop approval around the SDK. Autonomous compaction on by default here.
Streaming, checkpointing, persistence, interrupts. A Deep Agent is a LangGraph graph underneath — long jobs survive crashes and pauses.
Tracing and evaluation for agent runs. The autonomous-compaction work was validated against Terminal-Bench-2 via LangSmith. USD-billed at scale.
Standards it speaks. Deep Agents brings your own tools or any MCP server, and it can load Agent Skills as reusable, on-demand behaviours — so the harness plugs into the same open-standards layer as the rest of the agents tree rather than reinventing it.
Provenance, stated honestly. The middleware isn't all from one package: some ships in deepagents, some in langchain itself, and provider-specific pieces (Anthropic prompt caching, for instance) live in langchain-anthropic. That's normal for a LangChain-family library, but worth knowing when you go to pin versions — a "Deep Agents" behaviour may actually be governed by a dependency's release cadence.
One field note, clearly labelled as opinion: the LangChain engineers describe a stated preference for routing different models to different jobs — Gemini for multimodal, Claude for execution and SQL, a third for long prose. That's practitioner taste, not a benchmarked finding, and Deep Agents' model-agnosticism is what makes acting on it a one-line change rather than a rebuild.
This is not a "who wins" table — all three are the same stack at different levels of opinion. The question is only how much harness you want handed to you versus how much control you want to keep. LangChain's own guidance runs top to bottom.
| Dimension | Deep Agents | create_agent | Raw LangGraph |
|---|---|---|---|
| Harness level | Full, opinionated | Minimal | None — you build it |
| Out of the box | Planning, sub-agents, filesystem, compaction | Tool-calling loop + middleware hooks | Nodes, edges, state, checkpointer |
| Built on | create_agent | LangGraph | — |
| Best when | Long-horizon, high-context tasks | A standard agent with light needs | A bespoke agent-loop shape |
| Effort for deep work | Lowest | Medium — you add the scaffolding | Highest — you design it all |
The second comparison people actually mean is Deep Agents vs Claude Code or Codex — the closed harnesses it's modelled on. Those are polished, vendor-tuned, and tied to one model family. Deep Agents trades some of that polish for two things: it runs on any tool-calling model, and it's yours to modify — the middleware is open and swappable. If you're happy inside one vendor's tool and never need to change models, the proprietary harness is the smoother ride. If model-agnosticism or customisation is the point, Deep Agents is the reason to switch. There is no clean public benchmark pitting them head-to-head; don't trust one that claims to.
Deep Agents earns its overhead on tasks that are long, context-heavy, and decomposable — the patterns the primary sources actually name, not a customer-logo roster.
glob/grep, read and edit files, run sub-agents for isolated changes, and keep a live todo list across a multi-file task. This is the Claude Code shape, model-agnostic.An honest limit. Unlike LangGraph, Deep Agents doesn't yet have a public roster of named production case studies (the Klarna / Replit kind). It's a younger library. Treat the use cases above as the patterns it's designed for, not as claims about who's already running it at scale.
The harness is a real cost — middleware, compaction, sub-agent spawns all add overhead. On the right task that overhead buys you a working long-horizon agent; on the wrong one it's dead weight. Honest two-sided guidance follows.
create_agentDeep Agents is young and moving fast — autonomous compaction landed in early 2026 and the middleware surface is still settling. Pin your versions in production, and remember the provenance point: some behaviours are governed by langchain or langchain-anthropic releases, not deepagents alone. The durable artefact is your agent definition; expect to track runtime updates more actively than you would with a 1.0-stable framework.
Deep Agents' model-agnosticism isn't just a portability nicety in SA delivery — it's the compliance and cost lever. Same harness, different model node, no rebuild.
The whole value of a model-agnostic harness under POPIA is that the model is one node you can move. Prototype against Claude (US), then swap to a local Ollama- or vLLM-hosted open-weight running in africa-south1 or on-prem — the planning, sub-agents, filesystem, and compaction all stay identical. POPIA Section 72 cross-border-transfer becomes a per-deployment decision about one line of config, not an architecture rewrite. The harness is the durable asset; the model is the substitutable runtime.
Because Deep Agents runs on LangGraph, a long-horizon job is checkpointed and its working state lives on the filesystem. A load-shedding interruption or a sandbox timeout mid-research doesn't cost the whole run — it resumes from the last checkpoint. For SA teams running multi-hour agent jobs on unreliable power, that durability is a practical, not theoretical, benefit.
The harness itself is free MIT and self-hostable — no per-seat licence, no FX exposure on the library. The USD-billed piece is the same as the LangGraph leaf: LangSmith at production volume. Use the free tier through pilots; treat paid observability as a deliberate line item, or self-host an OpenTelemetry stack if FX exposure is the binding constraint. The model spend is yours to control precisely because you choose the model node.
Authored from the canonical langchain-ai/deepagents repo, the Deep Agents documentation and reference, and LangChain Inc.'s harness and autonomous-compaction posts. Last reviewed 2026-07-19.