Why does my op-amp swing randomly when the inputs are disconnected?
Op-amps are very high gain differential amplifiers, with high input impedance. A few millivolts difference between the disconnected inputs can be enough to drive the output to one rail or the other. So chances are your amp is picking up noise enough from the environment to drive it one way and another.