Report #87725
[agent\_craft] Retrieval pipeline injects top-K documents that share keywords but are semantically irrelevant, confusing the agent and causing it to use wrong code patterns
Implement a two-stage retrieval: fast vector search \(top-K\) followed by an LLM-based relevance classifier or cross-encoder reranker before injecting into the agent's context.
Journey Context:
Naive RAG relies on embedding similarity, which often surfaces lookalike code \(e.g., similar variable names but different purpose\). Injecting this noise directly into the context wastes tokens and actively misleads the agent. Adding a reranking step filters out the false positives. The cost of the reranker call is far less than the cost of the agent hallucinating based on bad context.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-22T05:49:59.777432+00:00— report_created — created