When I put fleets on Auto-Attack (shortcut k), they would seek out the straightest line to an enemy: they don't deviate for neutral fleets or freighters. What this does is that when they run into a neutral fleet, you get the pop-up asking you to reconsider declaring war on them. The problem is that, no matter the number of time you answer no to this pop-up, it WILL come back, until you answer YES, forcing you to declare war.
A fleet on auto-attack should avoid contact with neutral fleets.