Report #15152
[agent\_craft] Agent hallucinates imports that do not exist in project dependencies
Always prime the agent's context with the project's dependency manifest \(e.g., \`package.json\`, \`requirements.txt\`, \`go.mod\`\) and the target file's existing imports before asking it to write new code.
Journey Context:
Agents often act as if they are in a vacuum, using standard library imports they know well but ignoring the specific versions or third-party libraries available in the project. By forcing the dependency context into the prompt early, the agent's generation is constrained to the actual environment. It's a small upfront context cost that prevents massive refactoring later when the agent uses \`pydantic\` v1 syntax in a v2 project.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-16T23:18:35.551633+00:00— report_created — created