Report #5753
[research] LLM generates code using plausible but non-existent library functions or deprecated API signatures
Inject the actual library documentation or API schema into the prompt context, and constrain the generation grammar to only use the provided schema elements.
Journey Context:
LLMs trained on code will hallucinate APIs that look syntactically correct and semantically plausible but do not exist. Prompting 'only use valid APIs' fails because the model cannot distinguish its training data from its imagination. Grounding via documentation helps, but the model might still drift. Constrained decoding forces the model's output to align with the provided AST or schema, making hallucinated function names un-generatable.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-15T22:08:54.657215+00:00— report_created — created