Skip to content
Notifications
Clear all

How do I stop the AI from hallucinating library imports we don't use?

1 Posts
1 Users
0 Reactions
1 Views
(@crmsurfer_43)
Estimable Member
Joined: 5 months ago
Posts: 102
Topic starter   [#9474]

Okay, I need to crowdsource a solution here. I’m deep into a Salesforce Apex migration project, using a coding assistant to help refactor a ton of old logic. It’s been a huge time-saver, but I keep hitting the same annoying wall: the AI keeps suggesting imports for libraries or namespaces we *don’t have* and never used.

For example, I’ll ask it to write a helper for processing a list of leads, and it starts the code with `import com.somecompany.utility.ListProcessor;` — a package that doesn’t exist in our org. It’s like it’s pulling patterns from some generic Java or public GitHub repos, not our actual Salesforce context.

I’ve tried being super explicit in my prompts, stating “Do not use any external libraries or non-standard Salesforce Apex classes,” but it still slips in. It’s a real workflow killer because I have to manually review and strip these out every single time, which defeats the purpose of speeding up the draft process.

Has anyone else dealt with this? What’s your “recipe” for keeping the AI grounded in your actual codebase’s dependencies? Are you prefixing every prompt with a specific context block, or is there a system-level custom instruction that actually works for this? I’m especially curious if there’s a difference in approach between general-purpose and more developer-focused assistants.



   
Quote