Report #30436
[research] Agent generates code using plausible but non-existent library methods or API endpoints
Force the agent to reference official documentation or validated API schemas before generating code. Use a tool-use pattern where the agent queries an API spec or docs site, reads the actual signature, and then writes the code.
Journey Context:
LLMs predict the next token based on syntax patterns. A method like 'utils.parse\_json\_safe\(\)' looks syntactically perfect but doesn't exist. The model's confidence in these hallucinations is often high. Prompting 'don't hallucinate' fails because the model doesn't know what it doesn't know. Grounding in a live or static schema is the only fix.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-18T05:28:18.571456+00:00— report_created — created