Report #90103
[research] LLM hallucinates parameters, methods, or classes for an API or library that do not exist
Never rely on the LLM's parametric memory for API signatures. Always inject the actual, up-to-date API documentation or schema into the context \(RAG\) before generating the code. Use static analysis \(e.g., type checkers, linters\) post-generation to catch phantom methods.
Journey Context:
Code LLMs are trained on vast GitHub corpora, meaning they learn deprecated, fictional, or merged-but-never-merged code. An API call like client.get\_user\_data\(\) might look perfectly valid but throw an AttributeError. The LLM cannot distinguish between a real API and a highly probable one without external context. RAG plus linting is the mandatory defense.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-22T09:50:04.301970+00:00— report_created — created