Deep Agents/Context Engineering
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

TypeWhat It IsLifetimeExample
TransientCurrent conversation messagesThis run onlyUser messages, assistant responses, tool results
ToolData retrieved or computed during executionThis stepSearch results, file contents, API responses
Life-cyclePersistent knowledge across sessionsIndefiniteUser 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.