---
title: "Context Engineering with Deep Agents: How To Remember Without Keeping Everything In Context"
description: "Long-running agents suffer \"context rot\" as tool output, history and instructions accumulate, so Deep Agents moves context out of the active window via middleware hooks in the agent loop rather than deleting it."
url: "https://swe.quest/articles/context-engineering-with-deep-agents-how-to-remember-without-keeping-everything-1dc293ec006d2b0c"
canonical: "https://www.langchain.com/blog/context-engineering-deep-agents-remember"
source: "LangChain"
published: "2026-11-10"
difficulty: "medium"
kind: "Deep dive"
reading_minutes: 9
tags: ["ai-agents","llms"]
---

# Context Engineering with Deep Agents: How To Remember Without Keeping Everything In Context

A post on [LangChain](https://swe.quest/sources/langchain.md), published 2026-11-10, 9 min read, Deep dive. Original: [https://www.langchain.com/blog/context-engineering-deep-agents-remember](https://www.langchain.com/blog/context-engineering-deep-agents-remember)

## Summary

Long-running agents suffer "context rot" as tool output, history and instructions accumulate, so Deep Agents moves context out of the active window via middleware hooks in the agent loop rather than deleting it. FilesystemMiddleware offloads tool results over ~20,000 tokens (and user messages over 50,000) to files and shows only a preview. SummarizationMiddleware condenses older messages at 85% of the context window while keeping recent ones verbatim and writing the originals to recoverable files. SkillsMiddleware uses progressive disclosure to load task instructions only when relevant, subagents isolate noisy work in separate contexts, and MemoryMiddleware persists learned preferences in a plain markdown file that survives switching model providers.

Written by swe.quest, not by the author.

**Difficulty:** Medium: assumes a working developer; shows how it is built or done

## Topics

- [AI agents](https://swe.quest/tags/ai-agents.md) (AI & ML)
- [LLMs](https://swe.quest/tags/llms.md) (AI & ML)

## Prerequisites

- LLM context windows ([easy posts on LLMs](https://swe.quest/tags/llms.md?difficulty=easy))
- tool-calling agent loops

## Keywords

Deep Agents, LangChain, context engineering, SummarizationMiddleware, FilesystemMiddleware, SubAgentMiddleware, LangSmith

## Related posts

- [Context Management for Deep Agents](https://swe.quest/articles/context-management-for-deep-agents-dc1d776470c6aad5.md): LangChain · 2026-10-13 · Medium · 5 min read · AI agents, LLMs, Evaluation
  The Deep Agents SDK manages long-running agent context with three compression techniques triggered at fractions of the model's context window.
- [Organizing Context in a Multi-Agent Harness](https://swe.quest/articles/organizing-context-in-a-multi-agent-harness-ef9658a8a3139963.md): LangChain · 2026-09-08 · Medium · 6 min read · AI agents, LLMs
  Deep Agents adds subagent context modes: "isolated" (the default, a fresh context window with only the supervisor's task description) and "fork" (the subagent inherits the supervisor's full conversation history).
- [Context Engineering (Agent Memory) for AI Agents Starts with Retrieval](https://swe.quest/articles/context-engineering-agent-memory-for-ai-agents-starts-with-retrieval-4b7268c3138eae87.md): LangChain · 2026-11-10 · Medium · 11 min read · AI agents, RAG & retrieval, LLMs, Vector search
  Agent retrieval fails in three ways: inefficient searching, too much context at once, and irrelevant or stale context.
- [Revamping Skills in Deep Agents](https://swe.quest/articles/revamping-skills-in-deep-agents-04e79ba47ae89b3f.md): LangChain · 2026-10-08 · Medium · 7 min read · AI agents, LLMs, Python
  Deep Agents now supports binding tools to Agent Skills, pinning skills at runtime, and reloading skills mid-thread, extending progressive disclosure for libraries that grow to thousands of skills.
- [Managed Deep Agents delivers a better user experience for agents in production](https://swe.quest/articles/managed-deep-agents-delivers-a-better-user-experience-for-agents-in-production-3b6bfb172c71ce79.md): LangChain · 2026-10-08 · Medium · 8 min read · AI agents, Identity & auth, LLMs
  Managed Deep Agents 0.8 adds user-level memory, user-owned credentials, HTTP webhook channels, Slack file transfer and built-in Parallel web search.

Browse: [Latest posts](https://swe.quest/index.md) · [Topics](https://swe.quest/tags.md) · [Sources](https://swe.quest/sources.md) · [Topic map](https://swe.quest/map.md) · [Site guide (llms.txt)](https://swe.quest/llms.txt)
