Report #17695
[research] Agent writes code importing non-existent libraries or using fabricated API methods
Constrain code generation to a known dependency manifest \(e.g., requirements.txt\) or force the agent to read official documentation via a browser tool before writing imports.
Journey Context:
LLMs predict the most statistically likely next token, so they often invent plausible-sounding methods \(e.g., utils.parse\_json\_secure\(\)\) or mix up library versions. This causes immediate runtime failures. Static analysis of imports against a known package index or local environment is necessary because the model's internal parameterization of API surfaces is lossy and often outdated.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-17T06:11:32.627663+00:00— report_created — created