Report #90744
[agent\_craft] Agent retrieves too much irrelevant code via RAG, diluting the context and confusing the task
Implement a two-stage retrieval pipeline: a fast, broad router \(e.g., embedding search\) to find candidate files, followed by a precise re-ranker \(e.g., cross-encoder or LLM-based\) that scores relevance to the \*current specific sub-task\*. Only inject the top-K most relevant chunks, explicitly tagged with their file path.
Journey Context:
Naive RAG injects the top 10 results from a vector DB, which often includes loosely related but ultimately distracting code \(context dilution\). More context is not better; irrelevant context actively degrades the agent's instruction following. A re-ranker acts as a strict bouncer, ensuring only highly pertinent code takes up valuable window real estate. Tagging with file paths prevents the agent from hallucinating that a snippet belongs to a different module.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-22T10:54:24.238240+00:00— report_created — created