Let me see if I can help,
# PO505 - Is a circuit problem which was likely caused by the Idle Air Controller. After replacement has this code resolved?
# P0122 - indicates a low voltage in the throttle position sensor circuit. After replacement has this code resolved itself?
# P0171: This code indicates that the fuel system on the first bank of the engine is weak or that there is a vacuum leak near this side of the engine.
I will address the po171 which i would say is the telling code. It fits the description of your issue as well. The leak is causing the computer to read that the truck is running lean and thus it is attempting to send more gas which in turn acts like the vehicle is flooding.
You need to first check for vacuum and intake leaks. With the engine idling, spray each vacuum hose one by one with some carb cleaner. If idle changes when one is sprayed, then you need to replace that hose. If all ok, then repeat by spraying the base of the intake manifold with carb cleaner. If idle changes, then replace the intake manifold gasket
If ok, the fuel pressure needs to be checked. Fuel pressure at idle should be 44.2-54.2 psi (305-373 kPa). If lower than that, then replace fuel pump. If higher than that, then replace the fuel pressure regulator.
Report back and we will take it from there.
I hope this helps.
Cheers
Monte