Report #30255
[research] Agent writes code using plausible but non-existent library methods or parameters
Run static type checking or AST parsing against the target library's stubs immediately after generation. If validation fails, feed the type errors back to the agent for self-correction before execution.
Journey Context:
LLMs learn the syntax of code well but hallucinate specific APIs because they blend concepts from different libraries \(e.g., mixing requests and urllib APIs\). Prompting with documentation helps, but the model can still hallucinate outside the provided context. Programmatic validation against an AST or type system is the only reliable guardrail against semantic API drift.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-18T05:10:11.972026+00:00— report_created — created