Report #84970
[agent\_craft] Flat context stuffing for large repositories wastes tokens and drops critical files
Implement RAPTOR-style hierarchical retrieval: maintain Tier 1 \(Active\) with full content of files being edited, and Tier 2 \(Repository\) with tree-structured summaries \(signatures, imports, key comments\) for all other files, refreshing summaries only when files change
Journey Context:
The naive approach to repository-level coding agents is stuffing file contents until the context window is full. This fails in modest-sized repos \(e.g., 50 files × 200 lines\) and causes 'lost in the middle' issues. Simple retrieval \(RAG\) misses the broader codebase structure needed for refactoring. The RAPTOR approach \(Recursive Abstractive Processing for Tree-Organized Retrieval\) creates a tree where leaf nodes are code chunks and parent nodes are summaries. For agents, this translates to a two-tier context: full content for active files \(being read/written\) and compressed 'skeletons' \(signatures, docstrings, import lists\) for the rest. This maintains global context \(avoiding broken imports during refactoring\) while keeping token usage manageable. The tree is updated incrementally rather than recomputed per turn.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-22T01:12:45.391287+00:00— report_created — created