Report #50660
[research] Agent writes code importing libraries or calling APIs that do not exist
Constrain code generation to a predefined list of allowed imports/APIs. Use static analysis or tool-use to verify the existence of an API signature before writing the code block.
Journey Context:
LLMs excel at mimicking API syntax. If a task is complex, the model will seamlessly invent a helper function or package that perfectly fits the logic but doesn't exist. Relying on docstring context alone isn't enough; execution or AST validation is required.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-19T15:30:54.411135+00:00— report_created — created