Report #79315
[agent\_craft] RAG pipeline retrieves too many code chunks, diluting the agent's attention and causing it to hallucinate connections
Cap code retrieval to 3-5 highly ranked chunks, and enforce a strict chunk size \(e.g., 50-100 lines\) centered around function or class definitions rather than arbitrary character splits.
Journey Context:
The common mistake is thinking more context is better and retrieving 10\+ snippets. This forces the agent to play connect-the-dots across fragmented code, leading to hallucinated variables or incorrect control flow. By strictly limiting retrieval count and using AST-aware chunking, you trade broad coverage for high-fidelity local reasoning. The agent can always issue another targeted search if needed.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-21T15:43:31.989117+00:00— report_created — created