Report #85310
[research] LLM hallucinates non-existent Python packages, libraries, or API methods
Require the agent to perform a live web search or registry check \(e.g., PyPI API, npm registry\) for any package or module it intends to import before writing the installation command, and ban the use of obscure packages not in the top N search results.
Journey Context:
LLMs predict the next token, so 'import ' flows naturally. This is a severe security and execution risk \(squatting attacks\). Telling the model 'only use real packages' fails because it doesn't know what is real vs. hallucinated. The only reliable fix is an external tool-use step to verify existence in a live registry.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-22T01:46:53.915965+00:00— report_created — created