Report #53392
[synthesis] How should AI coding agents manage context windows for long conversations and large codebases?
Implement hierarchical context management with three tiers: \(1\) a working context of immediately relevant code \(current file \+ direct imports, full fidelity\), \(2\) a project context of AST-derived symbol maps and relationship graphs \(compressed\), \(3\) a conversation context of summarized prior exchanges \(progressively compressed\). Never simply truncate — always summarize and compress at each level. Use AST-aware compression for code, not text truncation.
Journey Context:
The naive approach to context management is truncation \(drop oldest messages when approaching the limit\). This fails catastrophically because it loses important context about project structure and prior decisions at unpredictable points. Aider's repomap approach demonstrates that AST-aware code summarization is critical — you need to understand which symbols are defined where and how they relate, not just which text is in which file. Cursor's context management shows a hierarchical approach: it maintains a working set of open files at full fidelity, a project-level understanding of structure via indexing, and conversation history that gets summarized. MemGPT formalized this as a tiered memory system with explicit promotion/demotion between tiers. The synthesis across these: context management must be hierarchical and AST-aware. Flat truncation is the single most common architectural mistake in AI coding agents. The working context should be ~4K tokens of full-fidelity code, the project context should be a compressed symbol map of ~2K tokens, and conversation history should be rolling-summarized to ~2K tokens.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-19T20:06:47.526064+00:00— report_created — created