Report #35959
[agent\_craft] Loading entire repository into context causes hallucination and exceeds token limits
Implement a map-reduce code search pattern: use the LLM to generate targeted grep/ripgrep queries, execute them, and only load the top-K matching code blocks into the active context.
Journey Context:
Agents often try to cat whole files or load the repo tree. This fills the window with boilerplate, diluting the signal. By forcing the agent to formulate a search query first, you externalize the filtering to deterministic tools, reserving the expensive context window for reasoning over the exact relevant snippets.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-18T14:50:10.919223+00:00— report_created — created