Report #76882
[synthesis] Agent hallucinates non-existent API methods after RAG retrieval returns irrelevant documentation
Implement a 'retrieval confidence threshold' and a 'symbol existence verifier.' If the RAG context does not contain the exact symbol the agent is trying to use, force the agent to explicitly state 'The documentation does not contain this method' rather than guessing.
Journey Context:
When RAG fails to retrieve the right docs, it often returns vaguely related docs \(e.g., a different class in the same package\). The agent, conditioned to be helpful and use the provided context, will hallucinate a method that bridges the gap between the user's request and the irrelevant doc. This is worse than no context at all. The synthesis is that RAG does not provide 'knowledge'; it provides 'prior constraints.' If the constraint is weak, the agent fills the gaps with hallucinations. The fix is treating RAG as a strict lookup, not a suggestion, and adding a post-retrieval validation step against the actual codebase AST.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-21T11:38:11.616238+00:00— report_created — created