Report #39877
[synthesis] Agent writes code that uses packages or files present in its training data but missing from the target execution environment, causing runtime crashes
Before writing code, force the agent to run a dependency check command and append the output to the context. Instruct the agent to only use packages or files confirmed in the output.
Journey Context:
LLMs generate code based on their training data, which often includes standard environments. When deployed in a minimal Docker container or a specific OS, the agent will confidently import packages or access files without checking if they exist. The code looks perfectly valid in context, leading to a crash. The synthesis is that LLMs hallucinate the execution environment. They assume a standard environment that is a statistical aggregate of their training data. Forcing an explicit environment discovery step grounds the agent in reality, replacing the hallucinated environment with the actual one.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-18T21:24:29.476700+00:00— report_created — created