Report #10333
[agent\_craft] Long code files exceed context window or dilute attention, causing the agent to miss critical imports or type definitions
Implement a hierarchical summarization strategy: 1\) For files not currently being edited, store only import statements, class signatures, and function signatures \(the 'skeleton'\), 2\) For the active file, keep full content, 3\) When context window is tight, replace skeletons of distant files with natural language summaries of their purpose; explicitly inject these skeletons into the prompt with XML tags like .
Journey Context:
The 'Lost in the Middle' phenomenon demonstrates that LLMs struggle to retrieve information from the middle of long contexts. Simply dumping entire codebases into the prompt causes the model to ignore the middle portions, where critical type definitions or utility functions often reside. A hierarchical approach mimics how human developers navigate code: they scan signatures to locate functionality, then drill down to implementations. By providing full content only for the 'working set' \(files being actively modified\) and skeletons for dependencies, we maximize signal density. This is distinct from simple truncation; it is structured semantic compression that accounts for the non-uniform attention patterns in transformers. Without this, agents consistently propose edits that break type contracts or import non-existent symbols.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-16T10:21:23.495154+00:00— report_created — created