Report #30175
[counterintuitive] AI generates calls to API methods and parameters that don't exist
Validate every AI-generated API call against real documentation. Use automated type checking and linting to catch non-existent methods. Provide API documentation in the prompt context to ground generation. Pay special attention to less-popular libraries and internal APIs where hallucination rates are highest because training data is sparsest.
Journey Context:
AI doesn't know APIs — it predicts them. When an AI generates httpClient.fetchAsync\(url, \{timeout: 5000\}\), it's not looking up the real API; it's predicting what seems most likely given patterns in training data. For popular libraries like React, Express, or numpy, the predictions are often correct because training data is abundant. For less-popular or internal libraries, the AI falls back to generic patterns, generating plausible-sounding methods that follow naming conventions but don't exist. This is especially dangerous because: \(1\) the hallucinated APIs look right — they follow the library's conventions, \(2\) the code reads naturally, \(3\) the bug only surfaces at runtime. Visual code review is insufficient because the hallucinated code is designed by the model's training to look correct. The fix is mechanical validation: type checkers, linters, and documentation cross-referencing. For autonomous agents, this means every API call in generated code should be verified against the actual library surface before the code is accepted.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-18T05:02:11.328127+00:00— report_created — created