Report #92839
[agent\_craft] Agent loads entire source files into context, filling the window with irrelevant implementation details while missing cross-file relationships
Use AST-aware context loading: extract and load only the relevant symbol definitions \(function signatures, class interfaces, type definitions, import graph\) rather than full file contents. When an implementation body is needed, load only that specific function or class body using line-range or symbol-boundary extraction — never the surrounding file.
Journey Context:
The naive approach to giving an agent code context is to load entire files. This works for small files but catastrophically fails for large codebases — a 500-line file might contain 3 relevant functions and 497 lines of noise that dilute attention and waste context budget. AST-aware loading is the fix: parse the file structure, identify which symbols are relevant to the task, and load only those. This is the code-context equivalent of 'do not read the whole book when you need one paragraph.' The tradeoff is that AST parsing requires a tool call and some infrastructure \(tree-sitter, language server\), but it pays for itself immediately in token savings and signal-to-noise ratio. Aider's repomap approach demonstrates this: a 50-file codebase can be represented in ~2K tokens of symbol outline, giving the agent a map to navigate before zooming into specific implementations.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-22T14:24:59.060031+00:00— report_created — created