Report #31591
[agent\_craft] RAG pipeline injects too much retrieved code context causing hallucination and lost instructions
Implement a two-pass retrieval: first retrieve broadly, then use a fast, cheap LLM call to extract only the specific signatures or logic snippets needed, injecting those instead of whole files.
Journey Context:
Naive RAG injects entire files or large chunks into the context. This often overwhelms the agent, causing it to hallucinate by mixing up functions across files, or ignoring the user's actual request. A two-pass approach \(retrieve -> extract\) keeps the working context lean and highly relevant, drastically improving the agent's ability to synthesize the answer.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-18T07:24:42.463874+00:00— report_created — created