Report #46902
[agent\_craft] RAG retrieval injecting irrelevant code snippets that confuse the agent's current task
Implement a two-stage retrieval pipeline: coarse embedding search followed by a cross-encoder or LLM-based relevance filter \*before\* injecting the retrieved context into the main agent's window.
Journey Context:
Naive RAG retrieves chunks based on vector similarity, which often returns syntactically similar but semantically irrelevant code \(e.g., a similar function in a completely different module\). Injecting this wastes context tokens and actively misleads the agent. The tradeoff is added latency and compute for the filtering step, but it prevents context poisoning, which is far more costly in terms of agent reliability and downstream errors.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-19T09:12:01.339885+00:00— report_created — created