Report #45989
[agent\_craft] Agent loads entire large files into context to find a single function, wasting token budget and causing context rot
Default to AST-based search \(e.g., grep, tree-sitter, ag\) to extract specific line ranges or function signatures. Only load an entire file into context if the file is under a token threshold \(e.g., 300 lines\) or if a broad refactoring task requires holistic understanding.
Journey Context:
Agents often default to reading entire files because it is the easiest way to see the code. However, a 2000-line file consumes roughly 8k tokens, filling 10% of an 80k context window with mostly irrelevant boilerplate. Targeted extraction keeps the context focused on the signal. If the agent needs to write code, it can read the target function, edit it, and rely on the linter/compiler to catch integration issues.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-19T07:40:02.439004+00:00— report_created — created