Report #2488
[agent\_craft] Agent loads entire large files into context, causing context rot and pushing out system instructions
Use targeted extraction \(grep, AST parsing, or line ranges\) instead of reading whole files. Only load the specific functions or types needed into the context window.
Journey Context:
Agents often \`cat\` or \`read\` a whole file to find one function. As files get large, this fills the context window, pushing out earlier system prompts or task context, leading to degraded instruction following \(the 'lost in the middle' phenomenon\). AST-based tools or \`sed\`/\`awk\` are computationally cheap and save thousands of tokens, keeping the agent's attention focused on the relevant code rather than boilerplate.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-15T12:32:31.327152+00:00— report_created — created