Report #16811
[research] LLM hallucinating non-existent package names, classes, or API methods that look syntactically valid
Provide the model with a curated manifest of allowed APIs/packages in the system prompt, and use AST parsing to validate generated code against the manifest before execution.
Journey Context:
LLMs excel at mimicking syntax but lack a live symbol table. They will confidently combine real prefixes with plausible-sounding suffixes \(e.g., pandas.fast\_merge\). Validating against a static manifest at generation time prevents runtime ImportError or AttributeError failures.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-17T03:45:43.250652+00:00— report_created — created