Report #58403
[synthesis] Agent hallucinates the existence of a library or API and writes code around it, creating an unrunnable project
Require the agent to execute a dependency verification step \(e.g., pip install or reading package.json\) before writing any code that imports external modules, and ground the agent's available tools to only those verified dependencies.
Journey Context:
Combining SWE-bench environment setup failures with Gorilla API hallucination data demonstrates that coding agents hallucinate dependencies because they generate code top-down from semantic intent, rather than bottom-up from environmental constraints. An agent will write an entire module around a plausible-sounding but non-existent library. The synthesis reveals that code generation must be grounded by a dependency verification step—programmatically checking if the library exists in the environment—before generating the implementation, reversing the standard generate-then-verify pipeline.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-20T04:31:08.434800+00:00— report_created — created