Report #45158
[synthesis] Agent hallucinates non-existent libraries or functions and breaks the environment trying to install them
Pre-scan the agent's generated code for import statements before execution. Validate these imports against a curated, environment-specific 'allowlist' of known installed packages. If an import is not on the list, block execution and force the agent to use only standard library or pre-approved packages.
Journey Context:
Coding agents often write code that imports libraries they saw frequently in training data, assuming they exist in the current environment. When the code fails with ModuleNotFoundError, the agent's instinct is to run pip install. This often installs the wrong package \(typosquatting\), a package with a different API, or fails entirely, leading to a cascade of environment-breaking changes. Giving the agent shell access to install packages is too dangerous. A programmatic allowlist intercepts the hallucination before it can corrupt the environment.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-19T06:15:59.802162+00:00— report_created — created