Surging Idle when Cold

This long tale of my 98 Ranger begins after having the timing belt replaced at 168000 miles.

When I first start the truck when it’s cold the idle will surge for 30 seconds or so, then it will level off and is fine (sort of). Within the first 10 minutes of driving, if I stop at a traffic light and go again, the temperature gauge will drop and it will hesitate, then be fine again. Also, occasionally when I stop at a light, at all operating temperatures, the idle will drop for a second and the voltage gauge will drop for a couple of seconds.

The Check Engine light has been intermittent, but codes have been P1131, P0171, P1132.

I’ve replaced the plugs, wires, intake gasket, pcv valve; had a tune up and cleaned the MAF sensor.

A repair log is at

Thanks for any insight someone can shed on this that 4 mechanics can’t.