Advanced10 min
Context Engineering in Deep Agents
Context engineering is THE core challenge in agent building. Deep Agents provides automatic context offloading, summarization, isolation via subagents, and progressive disclosure — keeping agents effective over long-running tasks.
Quick Reference
- →Three context types: Transient (current conversation), Tool (retrieved data), Life-cycle (persistent across sessions)
- →Automatic offloading: files >20K tokens are moved to filesystem, referenced by path instead of inline
- →Automatic summarization: at 85% context window usage, conversation is compressed
- →Context isolation: subagents get fresh context windows — main agent stays clean
- →Progressive disclosure via skills: load domain knowledge only when relevant
- →Middleware hooks (@dynamic_prompt, filesystem middleware) for custom context strategies
Three Types of Context
| Type | What It Is | Lifetime | Example |
|---|---|---|---|
| Transient | Current conversation messages | This run only | User messages, assistant responses, tool results |
| Tool | Data retrieved or computed during execution | This step | Search results, file contents, API responses |
| Life-cycle | Persistent knowledge across sessions | Indefinite | User preferences, project context, AGENTS.md |
The fundamental problem: all three types compete for the same fixed context window. A 200K token window sounds generous until your agent has 50 conversation turns, 10 retrieved documents, and a system prompt with skills and memory. Context engineering is about managing this budget so the agent always has what it needs without overflowing.