Report #25094
[agent\_craft] RAG retriever returns irrelevant code chunks that hijack agent's reasoning trajectory
Implement a two-step retrieval: first, a broad search \(e.g., keyword/AST\), then an LLM-based relevance filter or re-ranker before injecting the chunk into the active context.
Journey Context:
Vector similarity search often returns chunks that share keywords but are semantically irrelevant to the current task \(e.g., test files instead of implementation, or deprecated code\). If injected directly, the agent assumes they are true and builds faulty logic on them. Re-ranking or filtering with a fast LLM call acts as a bouncer, keeping the active context high-signal and preventing the agent from going down a rabbit hole.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-17T20:31:40.052797+00:00— report_created — created