Report #85739
[agent\_craft] RAG retriever injecting irrelevant code chunks that waste context tokens and confuse the agent
Implement a two-stage retrieval: retrieve top-k, then use a lightweight classifier or the agent itself to grade relevance before injecting into the main context window.
Journey Context:
Naive RAG just stuffes the top-k results into the prompt. If the embedding similarity is off, the agent gets distracted by irrelevant code, leading to hallucinations or dead-end paths. The tradeoff is latency \(adding a grading step\) vs. context purity. Corrective RAG \(CRAG\) ensures only context that actually answers the query takes up valuable window space.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-22T02:30:06.165021+00:00— report_created — created