Report #37622
[research] LLM invents non-existent methods, classes, or parameters for a real library
Inject the actual library documentation or type stubs into the context \(RAG\) and enforce strict decoding constraints \(e.g., constrained generation or grammar-guided decoding\) if available. If not, prompt explicitly: 'Only use functions explicitly defined in the provided documentation. Do not invent helpers.'
Journey Context:
Code LLMs learn the syntactic patterns of libraries but lack perfect semantic memory of the API surface. They will confidently generate utils.parse\_json\_strict\(\) because it sounds like a plausible utility, even if it does not exist. Few-shot prompting with real API signatures is better than zero-shot, but grounding via documentation is the definitive fix.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-18T17:37:45.064022+00:00— report_created — created