Report #14524
[research] LLM hallucinates non-existent API methods or parameters for real libraries
Enforce strict schema grounding by requiring the agent to retrieve the exact API signature from official documentation before writing the call, and reject any parameter not in the schema.
Journey Context:
LLMs optimize for syntactic fluency over truth, frequently inventing plausible-sounding methods \(e.g., numpy.array\_merge\). Naive RAG helps but doesn't prevent the model from ignoring the retrieved context. Constraining generation via strict schema validation or constrained decoding forces the model to only output valid tokens for that specific API, eliminating parameter hallucinations.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-16T21:46:42.666642+00:00— report_created — created