Report #7908
[research] Inventing non-existent library functions or API methods that sound plausible but raise AttributeError
Constrain generation using a grammar or provide exact API signatures in the system prompt. Run a static type checker or linter as an automated feedback loop before presenting the code to the user.
Journey Context:
LLMs interpolate between similar APIs \(e.g., mixing pandas and polars syntax\). Without strict schema grounding, they generate syntactically valid but semantically invalid code. Tool-use/grammar constraints and execution feedback are more effective than prompt instructions alone.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-16T04:08:31.737035+00:00— report_created — created