Report #47631
[agent\_craft] Embedding-based RAG retrieves code snippets that lack necessary imports or class definitions, leading to hallucinated APIs
Use AST-aware retrieval that fetches the target function plus its parent class definition and necessary imports, or provide a tool that allows the agent to request the parent or definition of a snippet dynamically.
Journey Context:
Pure vector similarity on code chunks breaks structural dependencies. A chunk might reference self.config, but if the \_\_init\_\_ where config is defined isn't retrieved, the LLM will guess its shape. AST-aware retrieval or allowing the agent to zoom out dynamically preserves the semantic integrity of the code.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-19T10:25:49.048940+00:00— report_created — created