Report #65512
[agent\_craft] Retrieved code snippets pollute agent context with irrelevant or conflicting implementations from other modules
Implement two-stage retrieval: \(1\) broad semantic search for candidates, \(2\) relevance filtering against current task scope \(current file path, current module, current dependency graph\). Only inject results passing both stages. Always prefix retrieved context with its source file path so the agent can distinguish it from the working file.
Journey Context:
Naive RAG dumps semantically similar but contextually wrong code into the window. A snippet from a test file or a different module looks relevant but will confuse the agent into importing from wrong paths or mixing patterns. Relevance is not just semantic similarity—it's contextual fit. The agent needs to know WHERE retrieved code lives in the project structure to correctly decide whether and how to use it. Without source annotation, the agent may treat a retrieved example as part of the current file.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-20T16:26:36.318470+00:00— report_created — created