# Building Deep Agents and Deploying in Production <!-- ref: @content/youtube/langchain/2026-07-31-building-deep-agents-and-deploying-in-production version: 3 updated_at: 2026-10-31T18:27:46.793Z --> Deep Agents (LangChain, 2026-07-31): An agent is a foundation model plus a harness, and the harness is everything around the model: prompts, memory, tools, file systems, sandboxes, and middleware. **[Watch on YouTube](https://www.youtube.com/watch?v=IZabCqyBJLg)** *Synthesized from a LangChain presenter on LangChain, 2026-07-31.* The talk is a meetup session given by a LangChain team member, who is not named in the transcript. It covers the open-source Deep Agents harness and the runtime problems LangChain ran into while putting its own long-running agents into production. ## Core Thesis An agent is a foundation model plus a harness, and the harness is everything around the model: prompts, memory, tools, file systems, sandboxes, and middleware. Deep Agents is LangChain's open-source harness with best practices already built in. As models and harnesses push the reliability-versus-agency frontier outward, the presenter recommends starting every agent as a deep agent. Long-running, multi-step agents also need a different runtime from standard infrastructure, one with durable execution, memory, agent-aware authentication, and human-in-the-loop as foundational capabilities. ## Key Insights - **"If you're not the model, you're the harness."** The presenter uses Claude Code as the example: its roughly **500,000 lines of source code** are all harness, there to get the best performance out of the underlying model (Opus, Sonnet, etc.). - **Harness primitives** include: - system prompts - memories, which is where current interest in "dreaming" and continual learning usually lives - tools, skills, MCP, and subagents - infrastructure the agent touches, such as file systems, sandboxes, and browsers - hooks and middleware - **Middleware** in Deep Agents can intercept model calls either before or after the model runs. That gives you a place for guardrails and custom pre- or post-processing. - **Open source vs. Claude Code.** Claude Code is closed source "if you don't count the leaks." Deep Agents is fully open, so you can tune the harness to your own task. - **The file system is called the current state of the art for context management.** Agents use it as a scratchpad and a reference store. Models were trained heavily on file-system interaction while coding agents like Claude Code and Codex were being optimized, so presenting data as files tends to improve performance. - **Other context-management levers** in Deep Agents are summarization, subagents, and planning. Each one keeps the minimum necessary information flowing to the model, which effectively extends the context window and keeps the model focused. - **Abstraction stack:** - Deep Agents is the highest level and the fastest path to production. - It sits on LangChain, which provides basic tool-calling agents. - LangChain sits on LangGraph, which provides the nodes, edges, and state. - **Migration is a one-line swap.** A ReAct-style LangChain agent (LLM, web-search tools, a guardrail up front, summarization at the end) becomes a deep agent by changing `create_agent` to `create_deep_agent`. That swap adds: - file-system middleware - a planning module - built-in file tools (`ls`, `cat`, `grep`) - a subagent tool, so the main LLM can spin up subagents on its own - **Composability goes both ways because everything is LangGraph underneath.** - A deterministic LangGraph workflow can use a deep agent as one node, for a single complex reasoning step. - A deep agent can orchestrate deterministic flows as its subagents. - **The reliability/agency Pareto curve keeps moving outward.** A few years ago, high reliability meant constraining the model's flexibility. Now a vanilla deep agent can handle many use cases reliably end to end. - **Standard infrastructure isn't built for long-running agents.** Production concerns include: - error recovery - autoscaling and parallel fan-out - resuming dropped sessions - human-in-the-loop - **Durable execution through checkpointing.** Complex agents push their context windows to the limit, which makes hallucinations and failures more likely as a run goes on. LangGraph and Deep Agents checkpoint state at basically every step, so a failure at **step 67 of 123** can resume from step 66 instead of starting over at step 1. - **Checkpoints also give you memory.** - **Short-term memory:** linking all the checkpoints in one session lets the agent recall something the user said five messages ago. - **Long-term memory:** pulling insights out of checkpoints across many sessions into a persistent store. A typical case is remembering that a user prefers Python examples. LangChain always includes a long-term memory store when it deploys deep agents to production. - **Authentication is different for agents.** - The baseline is acting on behalf of the user through OAuth, and never letting the agent do what the user can't. - RBAC and auth lines are blurrier for agents than for traditional apps. Giving a deterministic app Gmail send access is fine, but an agent sending **one** email may be acceptable while **a thousand** emails should trigger an investigation. - The presenter says this area is still being worked out. You need inbound auth handlers, outbound handlers for third parties, and RBAC. - **Human-in-the-loop is still essential** for most important tasks. The runtime needs to let users interrupt, stop, or approve agent actions, and it should stream progress back so users know a long-running agent is still working. ## Actionable Takeaways 1. **Default to a deep agent.** If you already have a LangChain tool-calling agent, replace `create_agent` with `create_deep_agent` to get file-system middleware, planning, the `ls`/`cat`/`grep` tools, and subagent spawning. 2. **Give the agent its data as a file system.** Models are strongly trained on file-system interfaces, and a scratchpad helps keep the context window lean. 3. **Use summarization, subagents, and planning** so only the minimum necessary context reaches the model. 4. **Put custom logic in middleware.** Add guardrails or pre/post-processing as hooks that run before or after model calls, rather than editing the core loop. 5. **Mix deterministic and agentic code on purpose.** Embed a deep agent as one LangGraph node for a hard reasoning step, or have a deep agent orchestrate deterministic subflows. 6. **Turn on per-step checkpointing** so long runs resume from the last good step (for example, step 66) instead of starting from step 1. 7. **Build two memory tiers from checkpoints:** - session-scoped short-term memory - a cross-session long-term store for durable user preferences, such as "always use Python" 8. **Design agent-specific auth:** - OAuth on-behalf-of flows as the minimum - inbound and outbound auth handlers - RBAC that watches behavioral thresholds like action volume, not just one-time permission grants 9. **Build human-in-the-loop into the runtime from the start.** Support interrupt, stop, and approve, and stream progress back to users during long runs. 10. **Plan runtime capacity** for autoscaling, parallel fan-out, and resuming dropped sessions before shipping long-running agents. ## Notable Quotes > "If you're not the model, you're the harness." — LangChain presenter > "The file system is probably the state-of-the-art when it comes to context management today." — LangChain presenter > "Our recommendation when it comes to building agents is to always start with a deep agent." — LangChain presenter > "Standard infrastructure in short is not really built for longunning complex agents." — LangChain presenter > "You might be okay with an agent sending one email on your behalf… [but not] a thousand emails." — LangChain presenter --- *You're reading a protocol on [protocol.supply](https://protocol.supply) — hosted, searchable knowledge for AI agents. Think Agent Skills, as an API: bootstrap once (`curl -sL https://api.protocol.supply/bootstrap`), search (`/search?q=…`), fetch (`/@repo/slug`).* *Any skill can become a protocol, and any protocol installs as a local skill — tell your agent "install this as a skill" or see [`@protocol/protocol-to-skill`](https://api.protocol.supply/@protocol/protocol-to-skill).*