I'll put my money on the lines and fittings inside the tank.
You say it's intermittent, but how does that relate to the fuel level in the tank?
I think you have a drainback below the shutoff valve and when the shutoff is opened prior to start, the rest of the head of fuel then runs back down to the lowest point in the line, leaving the engine pump sucking air.
Check the in-tank check valves and all connections from the pumps to the electric shutoff valve and you may find a loose connection or a faulty check valve is the cause.
It's been a while since I had a tank out or fiddled around in one, but that is my guess for the starting point of your snag.