The house is on a hill, with the main floor level with the pool. The equipment is in a room in a floor below. There is no easy way of moving the position of those valves.

This didn't use to be a problem. I am not sure when or how it started. I made small changes here and there. For instance, I added a separate loop, with two diverter valves, to reuse the same pump, filter, heater, and chlorinator, with a hot tub, so some of the pipes changes. Evidently some of those changes were enough to create the oscillation.