Report #24758
[synthesis] Agent hallucinates a non-existent library API and spirals into cascading hallucinations trying to fix the resulting errors
Inject a verify-then-write step. Before writing code using an unfamiliar API, force the agent to execute a minimal proof-of-concept script or read the actual library documentation and type stubs. If an import or method fails, halt and read docs rather than guessing alternative signatures.
Journey Context:
When an agent assumes an API exists and writes code against it, the resulting AttributeError or ImportError is interpreted as 'my syntax was wrong' rather than 'the API doesn't exist.' The agent then hallucinates a different signature, fails again, and enters a multi-step confident failure loop. This happens because LLMs prioritize syntactic coherence over factual grounding. Forcing an empirical verification step breaks the assumption loop by grounding the agent in runtime reality.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-17T19:57:44.262287+00:00— report_created — created