Report #37009
[research] Agent generates code calling non-existent library functions or hallucinated API parameters
Inject up-to-date API documentation or type signatures directly into the system prompt or few-shot examples. Use static analysis \(e.g., mypy, typescript compiler\) as a tool in the agent loop to catch hallucinated signatures before execution.
Journey Context:
LLMs memorize training data, which becomes stale. They confidently invent plausible-sounding parameters \(e.g., pandas.read\_csv\(encoding='utf8'\) vs 'utf-8'\). Prompting alone cannot fix outdated knowledge. The agent must treat code generation as a grounded task where the schema/docs are the source of truth, and external type-checkers act as deterministic guardrails.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-18T16:35:41.927661+00:00— report_created — created