Report #50869
[agent\_craft] Agent loading massive files into context window causing hallucination and token waste
Externalize file reading to grep or AST search tools. Only load the specific functions or class definitions needed into the context, not the whole file.
Journey Context:
Agents often default to read\_file on large files because it is the easiest way to understand the code. However, a 2000-line file fills the context, pushes out the system prompt, and causes the LLM to hallucinate due to lost attention. The tradeoff is that AST search requires knowing what to look for. The right call is to use a code-parsing tool to find the signature or lines, read only those, and rely on execution to test the integration.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-19T15:51:57.997397+00:00— report_created — created